

<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>LLVM’s Analysis and Transform Passes &#8212; LLVM 9 documentation</title>
    <link rel="stylesheet" href="_static/llvm-theme.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
    <script src="_static/jquery.js"></script>
    <script src="_static/underscore.js"></script>
    <script src="_static/doctools.js"></script>
    <script src="_static/language_data.js"></script>
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="YAML I/O" href="YamlIO.html" />
    <link rel="prev" title="LLVM 9.0.0 Release Notes" href="ReleaseNotes.html" />
<style type="text/css">
  table.right { float: right; margin-left: 20px; }
  table.right td { border: 1px solid #ccc; }
</style>

  </head><body>
<div class="logo">
  <a href="index.html">
    <img src="_static/logo.png"
         alt="LLVM Logo" width="250" height="88"/></a>
</div>

    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="YamlIO.html" title="YAML I/O"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="ReleaseNotes.html" title="LLVM 9.0.0 Release Notes"
             accesskey="P">previous</a> |</li>
  <li><a href="http://llvm.org/">LLVM Home</a>&nbsp;|&nbsp;</li>
  <li><a href="index.html">Documentation</a>&raquo;</li>

        <li class="nav-item nav-item-this"><a href="">LLVM’s Analysis and Transform Passes</a></li> 
      </ul>
    </div>


    <div class="document">
      <div class="documentwrapper">
          <div class="body" role="main">
            
  <div class="section" id="llvm-s-analysis-and-transform-passes">
<h1>LLVM’s Analysis and Transform Passes<a class="headerlink" href="#llvm-s-analysis-and-transform-passes" title="Permalink to this headline">¶</a></h1>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><p><a class="reference internal" href="#introduction" id="id1">Introduction</a></p></li>
<li><p><a class="reference internal" href="#analysis-passes" id="id2">Analysis Passes</a></p>
<ul>
<li><p><a class="reference internal" href="#aa-eval-exhaustive-alias-analysis-precision-evaluator" id="id3"><code class="docutils literal notranslate"><span class="pre">-aa-eval</span></code>: Exhaustive Alias Analysis Precision Evaluator</a></p></li>
<li><p><a class="reference internal" href="#basicaa-basic-alias-analysis-stateless-aa-impl" id="id4"><code class="docutils literal notranslate"><span class="pre">-basicaa</span></code>: Basic Alias Analysis (stateless AA impl)</a></p></li>
<li><p><a class="reference internal" href="#basiccg-basic-callgraph-construction" id="id5"><code class="docutils literal notranslate"><span class="pre">-basiccg</span></code>: Basic CallGraph Construction</a></p></li>
<li><p><a class="reference internal" href="#count-aa-count-alias-analysis-query-responses" id="id6"><code class="docutils literal notranslate"><span class="pre">-count-aa</span></code>: Count Alias Analysis Query Responses</a></p></li>
<li><p><a class="reference internal" href="#da-dependence-analysis" id="id7"><code class="docutils literal notranslate"><span class="pre">-da</span></code>: Dependence Analysis</a></p></li>
<li><p><a class="reference internal" href="#debug-aa-aa-use-debugger" id="id8"><code class="docutils literal notranslate"><span class="pre">-debug-aa</span></code>: AA use debugger</a></p></li>
<li><p><a class="reference internal" href="#domfrontier-dominance-frontier-construction" id="id9"><code class="docutils literal notranslate"><span class="pre">-domfrontier</span></code>: Dominance Frontier Construction</a></p></li>
<li><p><a class="reference internal" href="#domtree-dominator-tree-construction" id="id10"><code class="docutils literal notranslate"><span class="pre">-domtree</span></code>: Dominator Tree Construction</a></p></li>
<li><p><a class="reference internal" href="#dot-callgraph-print-call-graph-to-dot-file" id="id11"><code class="docutils literal notranslate"><span class="pre">-dot-callgraph</span></code>: Print Call Graph to “dot” file</a></p></li>
<li><p><a class="reference internal" href="#dot-cfg-print-cfg-of-function-to-dot-file" id="id12"><code class="docutils literal notranslate"><span class="pre">-dot-cfg</span></code>: Print CFG of function to “dot” file</a></p></li>
<li><p><a class="reference internal" href="#dot-cfg-only-print-cfg-of-function-to-dot-file-with-no-function-bodies" id="id13"><code class="docutils literal notranslate"><span class="pre">-dot-cfg-only</span></code>: Print CFG of function to “dot” file (with no function bodies)</a></p></li>
<li><p><a class="reference internal" href="#dot-dom-print-dominance-tree-of-function-to-dot-file" id="id14"><code class="docutils literal notranslate"><span class="pre">-dot-dom</span></code>: Print dominance tree of function to “dot” file</a></p></li>
<li><p><a class="reference internal" href="#dot-dom-only-print-dominance-tree-of-function-to-dot-file-with-no-function-bodies" id="id15"><code class="docutils literal notranslate"><span class="pre">-dot-dom-only</span></code>: Print dominance tree of function to “dot” file (with no function bodies)</a></p></li>
<li><p><a class="reference internal" href="#dot-postdom-print-postdominance-tree-of-function-to-dot-file" id="id16"><code class="docutils literal notranslate"><span class="pre">-dot-postdom</span></code>: Print postdominance tree of function to “dot” file</a></p></li>
<li><p><a class="reference internal" href="#dot-postdom-only-print-postdominance-tree-of-function-to-dot-file-with-no-function-bodies" id="id17"><code class="docutils literal notranslate"><span class="pre">-dot-postdom-only</span></code>: Print postdominance tree of function to “dot” file (with no function bodies)</a></p></li>
<li><p><a class="reference internal" href="#globalsmodref-aa-simple-mod-ref-analysis-for-globals" id="id18"><code class="docutils literal notranslate"><span class="pre">-globalsmodref-aa</span></code>: Simple mod/ref analysis for globals</a></p></li>
<li><p><a class="reference internal" href="#instcount-counts-the-various-types-of-instructions" id="id19"><code class="docutils literal notranslate"><span class="pre">-instcount</span></code>: Counts the various types of <code class="docutils literal notranslate"><span class="pre">Instruction</span></code>s</a></p></li>
<li><p><a class="reference internal" href="#intervals-interval-partition-construction" id="id20"><code class="docutils literal notranslate"><span class="pre">-intervals</span></code>: Interval Partition Construction</a></p></li>
<li><p><a class="reference internal" href="#iv-users-induction-variable-users" id="id21"><code class="docutils literal notranslate"><span class="pre">-iv-users</span></code>: Induction Variable Users</a></p></li>
<li><p><a class="reference internal" href="#lazy-value-info-lazy-value-information-analysis" id="id22"><code class="docutils literal notranslate"><span class="pre">-lazy-value-info</span></code>: Lazy Value Information Analysis</a></p></li>
<li><p><a class="reference internal" href="#libcall-aa-libcall-alias-analysis" id="id23"><code class="docutils literal notranslate"><span class="pre">-libcall-aa</span></code>: LibCall Alias Analysis</a></p></li>
<li><p><a class="reference internal" href="#lint-statically-lint-checks-llvm-ir" id="id24"><code class="docutils literal notranslate"><span class="pre">-lint</span></code>: Statically lint-checks LLVM IR</a></p></li>
<li><p><a class="reference internal" href="#loops-natural-loop-information" id="id25"><code class="docutils literal notranslate"><span class="pre">-loops</span></code>: Natural Loop Information</a></p></li>
<li><p><a class="reference internal" href="#memdep-memory-dependence-analysis" id="id26"><code class="docutils literal notranslate"><span class="pre">-memdep</span></code>: Memory Dependence Analysis</a></p></li>
<li><p><a class="reference internal" href="#module-debuginfo-decodes-module-level-debug-info" id="id27"><code class="docutils literal notranslate"><span class="pre">-module-debuginfo</span></code>: Decodes module-level debug info</a></p></li>
<li><p><a class="reference internal" href="#postdomfrontier-post-dominance-frontier-construction" id="id28"><code class="docutils literal notranslate"><span class="pre">-postdomfrontier</span></code>: Post-Dominance Frontier Construction</a></p></li>
<li><p><a class="reference internal" href="#postdomtree-post-dominator-tree-construction" id="id29"><code class="docutils literal notranslate"><span class="pre">-postdomtree</span></code>: Post-Dominator Tree Construction</a></p></li>
<li><p><a class="reference internal" href="#print-alias-sets-alias-set-printer" id="id30"><code class="docutils literal notranslate"><span class="pre">-print-alias-sets</span></code>: Alias Set Printer</a></p></li>
<li><p><a class="reference internal" href="#print-callgraph-print-a-call-graph" id="id31"><code class="docutils literal notranslate"><span class="pre">-print-callgraph</span></code>: Print a call graph</a></p></li>
<li><p><a class="reference internal" href="#print-callgraph-sccs-print-sccs-of-the-call-graph" id="id32"><code class="docutils literal notranslate"><span class="pre">-print-callgraph-sccs</span></code>: Print SCCs of the Call Graph</a></p></li>
<li><p><a class="reference internal" href="#print-cfg-sccs-print-sccs-of-each-function-cfg" id="id33"><code class="docutils literal notranslate"><span class="pre">-print-cfg-sccs</span></code>: Print SCCs of each function CFG</a></p></li>
<li><p><a class="reference internal" href="#print-dom-info-dominator-info-printer" id="id34"><code class="docutils literal notranslate"><span class="pre">-print-dom-info</span></code>: Dominator Info Printer</a></p></li>
<li><p><a class="reference internal" href="#print-externalfnconstants-print-external-fn-callsites-passed-constants" id="id35"><code class="docutils literal notranslate"><span class="pre">-print-externalfnconstants</span></code>: Print external fn callsites passed constants</a></p></li>
<li><p><a class="reference internal" href="#print-function-print-function-to-stderr" id="id36"><code class="docutils literal notranslate"><span class="pre">-print-function</span></code>: Print function to stderr</a></p></li>
<li><p><a class="reference internal" href="#print-module-print-module-to-stderr" id="id37"><code class="docutils literal notranslate"><span class="pre">-print-module</span></code>: Print module to stderr</a></p></li>
<li><p><a class="reference internal" href="#print-used-types-find-used-types" id="id38"><code class="docutils literal notranslate"><span class="pre">-print-used-types</span></code>: Find Used Types</a></p></li>
<li><p><a class="reference internal" href="#regions-detect-single-entry-single-exit-regions" id="id39"><code class="docutils literal notranslate"><span class="pre">-regions</span></code>: Detect single entry single exit regions</a></p></li>
<li><p><a class="reference internal" href="#scalar-evolution-scalar-evolution-analysis" id="id40"><code class="docutils literal notranslate"><span class="pre">-scalar-evolution</span></code>: Scalar Evolution Analysis</a></p></li>
<li><p><a class="reference internal" href="#scev-aa-scalarevolution-based-alias-analysis" id="id41"><code class="docutils literal notranslate"><span class="pre">-scev-aa</span></code>: ScalarEvolution-based Alias Analysis</a></p></li>
<li><p><a class="reference internal" href="#stack-safety-stack-safety-analysis" id="id42"><code class="docutils literal notranslate"><span class="pre">-stack-safety</span></code>: Stack Safety Analysis</a></p></li>
<li><p><a class="reference internal" href="#targetdata-target-data-layout" id="id43"><code class="docutils literal notranslate"><span class="pre">-targetdata</span></code>: Target Data Layout</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#transform-passes" id="id44">Transform Passes</a></p>
<ul>
<li><p><a class="reference internal" href="#adce-aggressive-dead-code-elimination" id="id45"><code class="docutils literal notranslate"><span class="pre">-adce</span></code>: Aggressive Dead Code Elimination</a></p></li>
<li><p><a class="reference internal" href="#always-inline-inliner-for-always-inline-functions" id="id46"><code class="docutils literal notranslate"><span class="pre">-always-inline</span></code>: Inliner for <code class="docutils literal notranslate"><span class="pre">always_inline</span></code> functions</a></p></li>
<li><p><a class="reference internal" href="#argpromotion-promote-by-reference-arguments-to-scalars" id="id47"><code class="docutils literal notranslate"><span class="pre">-argpromotion</span></code>: Promote ‘by reference’ arguments to scalars</a></p></li>
<li><p><a class="reference internal" href="#bb-vectorize-basic-block-vectorization" id="id48"><code class="docutils literal notranslate"><span class="pre">-bb-vectorize</span></code>: Basic-Block Vectorization</a></p></li>
<li><p><a class="reference internal" href="#block-placement-profile-guided-basic-block-placement" id="id49"><code class="docutils literal notranslate"><span class="pre">-block-placement</span></code>: Profile Guided Basic Block Placement</a></p></li>
<li><p><a class="reference internal" href="#break-crit-edges-break-critical-edges-in-cfg" id="id50"><code class="docutils literal notranslate"><span class="pre">-break-crit-edges</span></code>: Break critical edges in CFG</a></p></li>
<li><p><a class="reference internal" href="#codegenprepare-optimize-for-code-generation" id="id51"><code class="docutils literal notranslate"><span class="pre">-codegenprepare</span></code>: Optimize for code generation</a></p></li>
<li><p><a class="reference internal" href="#constmerge-merge-duplicate-global-constants" id="id52"><code class="docutils literal notranslate"><span class="pre">-constmerge</span></code>: Merge Duplicate Global Constants</a></p></li>
<li><p><a class="reference internal" href="#constprop-simple-constant-propagation" id="id53"><code class="docutils literal notranslate"><span class="pre">-constprop</span></code>: Simple constant propagation</a></p></li>
<li><p><a class="reference internal" href="#dce-dead-code-elimination" id="id54"><code class="docutils literal notranslate"><span class="pre">-dce</span></code>: Dead Code Elimination</a></p></li>
<li><p><a class="reference internal" href="#deadargelim-dead-argument-elimination" id="id55"><code class="docutils literal notranslate"><span class="pre">-deadargelim</span></code>: Dead Argument Elimination</a></p></li>
<li><p><a class="reference internal" href="#deadtypeelim-dead-type-elimination" id="id56"><code class="docutils literal notranslate"><span class="pre">-deadtypeelim</span></code>: Dead Type Elimination</a></p></li>
<li><p><a class="reference internal" href="#die-dead-instruction-elimination" id="id57"><code class="docutils literal notranslate"><span class="pre">-die</span></code>: Dead Instruction Elimination</a></p></li>
<li><p><a class="reference internal" href="#dse-dead-store-elimination" id="id58"><code class="docutils literal notranslate"><span class="pre">-dse</span></code>: Dead Store Elimination</a></p></li>
<li><p><a class="reference internal" href="#functionattrs-deduce-function-attributes" id="id59"><code class="docutils literal notranslate"><span class="pre">-functionattrs</span></code>: Deduce function attributes</a></p></li>
<li><p><a class="reference internal" href="#globaldce-dead-global-elimination" id="id60"><code class="docutils literal notranslate"><span class="pre">-globaldce</span></code>: Dead Global Elimination</a></p></li>
<li><p><a class="reference internal" href="#globalopt-global-variable-optimizer" id="id61"><code class="docutils literal notranslate"><span class="pre">-globalopt</span></code>: Global Variable Optimizer</a></p></li>
<li><p><a class="reference internal" href="#gvn-global-value-numbering" id="id62"><code class="docutils literal notranslate"><span class="pre">-gvn</span></code>: Global Value Numbering</a></p></li>
<li><p><a class="reference internal" href="#indvars-canonicalize-induction-variables" id="id63"><code class="docutils literal notranslate"><span class="pre">-indvars</span></code>: Canonicalize Induction Variables</a></p></li>
<li><p><a class="reference internal" href="#inline-function-integration-inlining" id="id64"><code class="docutils literal notranslate"><span class="pre">-inline</span></code>: Function Integration/Inlining</a></p></li>
<li><p><a class="reference internal" href="#instcombine-combine-redundant-instructions" id="id65"><code class="docutils literal notranslate"><span class="pre">-instcombine</span></code>: Combine redundant instructions</a></p></li>
<li><p><a class="reference internal" href="#aggressive-instcombine-combine-expression-patterns" id="id66"><code class="docutils literal notranslate"><span class="pre">-aggressive-instcombine</span></code>: Combine expression patterns</a></p></li>
<li><p><a class="reference internal" href="#internalize-internalize-global-symbols" id="id67"><code class="docutils literal notranslate"><span class="pre">-internalize</span></code>: Internalize Global Symbols</a></p></li>
<li><p><a class="reference internal" href="#ipconstprop-interprocedural-constant-propagation" id="id68"><code class="docutils literal notranslate"><span class="pre">-ipconstprop</span></code>: Interprocedural constant propagation</a></p></li>
<li><p><a class="reference internal" href="#ipsccp-interprocedural-sparse-conditional-constant-propagation" id="id69"><code class="docutils literal notranslate"><span class="pre">-ipsccp</span></code>: Interprocedural Sparse Conditional Constant Propagation</a></p></li>
<li><p><a class="reference internal" href="#jump-threading-jump-threading" id="id70"><code class="docutils literal notranslate"><span class="pre">-jump-threading</span></code>: Jump Threading</a></p></li>
<li><p><a class="reference internal" href="#lcssa-loop-closed-ssa-form-pass" id="id71"><code class="docutils literal notranslate"><span class="pre">-lcssa</span></code>: Loop-Closed SSA Form Pass</a></p></li>
<li><p><a class="reference internal" href="#licm-loop-invariant-code-motion" id="id72"><code class="docutils literal notranslate"><span class="pre">-licm</span></code>: Loop Invariant Code Motion</a></p></li>
<li><p><a class="reference internal" href="#loop-deletion-delete-dead-loops" id="id73"><code class="docutils literal notranslate"><span class="pre">-loop-deletion</span></code>: Delete dead loops</a></p></li>
<li><p><a class="reference internal" href="#loop-extract-extract-loops-into-new-functions" id="id74"><code class="docutils literal notranslate"><span class="pre">-loop-extract</span></code>: Extract loops into new functions</a></p></li>
<li><p><a class="reference internal" href="#loop-extract-single-extract-at-most-one-loop-into-a-new-function" id="id75"><code class="docutils literal notranslate"><span class="pre">-loop-extract-single</span></code>: Extract at most one loop into a new function</a></p></li>
<li><p><a class="reference internal" href="#loop-reduce-loop-strength-reduction" id="id76"><code class="docutils literal notranslate"><span class="pre">-loop-reduce</span></code>: Loop Strength Reduction</a></p></li>
<li><p><a class="reference internal" href="#loop-rotate-rotate-loops" id="id77"><code class="docutils literal notranslate"><span class="pre">-loop-rotate</span></code>: Rotate Loops</a></p></li>
<li><p><a class="reference internal" href="#loop-simplify-canonicalize-natural-loops" id="id78"><code class="docutils literal notranslate"><span class="pre">-loop-simplify</span></code>: Canonicalize natural loops</a></p></li>
<li><p><a class="reference internal" href="#loop-unroll-unroll-loops" id="id79"><code class="docutils literal notranslate"><span class="pre">-loop-unroll</span></code>: Unroll loops</a></p></li>
<li><p><a class="reference internal" href="#loop-unroll-and-jam-unroll-and-jam-loops" id="id80"><code class="docutils literal notranslate"><span class="pre">-loop-unroll-and-jam</span></code>: Unroll and Jam loops</a></p></li>
<li><p><a class="reference internal" href="#loop-unswitch-unswitch-loops" id="id81"><code class="docutils literal notranslate"><span class="pre">-loop-unswitch</span></code>: Unswitch loops</a></p></li>
<li><p><a class="reference internal" href="#loweratomic-lower-atomic-intrinsics-to-non-atomic-form" id="id82"><code class="docutils literal notranslate"><span class="pre">-loweratomic</span></code>: Lower atomic intrinsics to non-atomic form</a></p></li>
<li><p><a class="reference internal" href="#lowerinvoke-lower-invokes-to-calls-for-unwindless-code-generators" id="id83"><code class="docutils literal notranslate"><span class="pre">-lowerinvoke</span></code>: Lower invokes to calls, for unwindless code generators</a></p></li>
<li><p><a class="reference internal" href="#lowerswitch-lower-switchinsts-to-branches" id="id84"><code class="docutils literal notranslate"><span class="pre">-lowerswitch</span></code>: Lower <code class="docutils literal notranslate"><span class="pre">SwitchInst</span></code>s to branches</a></p></li>
<li><p><a class="reference internal" href="#mem2reg-promote-memory-to-register" id="id85"><code class="docutils literal notranslate"><span class="pre">-mem2reg</span></code>: Promote Memory to Register</a></p></li>
<li><p><a class="reference internal" href="#memcpyopt-memcpy-optimization" id="id86"><code class="docutils literal notranslate"><span class="pre">-memcpyopt</span></code>: MemCpy Optimization</a></p></li>
<li><p><a class="reference internal" href="#mergefunc-merge-functions" id="id87"><code class="docutils literal notranslate"><span class="pre">-mergefunc</span></code>: Merge Functions</a></p></li>
<li><p><a class="reference internal" href="#mergereturn-unify-function-exit-nodes" id="id88"><code class="docutils literal notranslate"><span class="pre">-mergereturn</span></code>: Unify function exit nodes</a></p></li>
<li><p><a class="reference internal" href="#partial-inliner-partial-inliner" id="id89"><code class="docutils literal notranslate"><span class="pre">-partial-inliner</span></code>: Partial Inliner</a></p></li>
<li><p><a class="reference internal" href="#prune-eh-remove-unused-exception-handling-info" id="id90"><code class="docutils literal notranslate"><span class="pre">-prune-eh</span></code>: Remove unused exception handling info</a></p></li>
<li><p><a class="reference internal" href="#reassociate-reassociate-expressions" id="id91"><code class="docutils literal notranslate"><span class="pre">-reassociate</span></code>: Reassociate expressions</a></p></li>
<li><p><a class="reference internal" href="#reg2mem-demote-all-values-to-stack-slots" id="id92"><code class="docutils literal notranslate"><span class="pre">-reg2mem</span></code>: Demote all values to stack slots</a></p></li>
<li><p><a class="reference internal" href="#sroa-scalar-replacement-of-aggregates" id="id93"><code class="docutils literal notranslate"><span class="pre">-sroa</span></code>: Scalar Replacement of Aggregates</a></p></li>
<li><p><a class="reference internal" href="#sccp-sparse-conditional-constant-propagation" id="id94"><code class="docutils literal notranslate"><span class="pre">-sccp</span></code>: Sparse Conditional Constant Propagation</a></p></li>
<li><p><a class="reference internal" href="#simplifycfg-simplify-the-cfg" id="id95"><code class="docutils literal notranslate"><span class="pre">-simplifycfg</span></code>: Simplify the CFG</a></p></li>
<li><p><a class="reference internal" href="#sink-code-sinking" id="id96"><code class="docutils literal notranslate"><span class="pre">-sink</span></code>: Code sinking</a></p></li>
<li><p><a class="reference internal" href="#strip-strip-all-symbols-from-a-module" id="id97"><code class="docutils literal notranslate"><span class="pre">-strip</span></code>: Strip all symbols from a module</a></p></li>
<li><p><a class="reference internal" href="#strip-dead-debug-info-strip-debug-info-for-unused-symbols" id="id98"><code class="docutils literal notranslate"><span class="pre">-strip-dead-debug-info</span></code>: Strip debug info for unused symbols</a></p></li>
<li><p><a class="reference internal" href="#strip-dead-prototypes-strip-unused-function-prototypes" id="id99"><code class="docutils literal notranslate"><span class="pre">-strip-dead-prototypes</span></code>: Strip Unused Function Prototypes</a></p></li>
<li><p><a class="reference internal" href="#strip-debug-declare-strip-all-llvm-dbg-declare-intrinsics" id="id100"><code class="docutils literal notranslate"><span class="pre">-strip-debug-declare</span></code>: Strip all <code class="docutils literal notranslate"><span class="pre">llvm.dbg.declare</span></code> intrinsics</a></p></li>
<li><p><a class="reference internal" href="#strip-nondebug-strip-all-symbols-except-dbg-symbols-from-a-module" id="id101"><code class="docutils literal notranslate"><span class="pre">-strip-nondebug</span></code>: Strip all symbols, except dbg symbols, from a module</a></p></li>
<li><p><a class="reference internal" href="#tailcallelim-tail-call-elimination" id="id102"><code class="docutils literal notranslate"><span class="pre">-tailcallelim</span></code>: Tail Call Elimination</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#utility-passes" id="id103">Utility Passes</a></p>
<ul>
<li><p><a class="reference internal" href="#deadarghax0r-dead-argument-hacking-bugpoint-use-only-do-not-use" id="id104"><code class="docutils literal notranslate"><span class="pre">-deadarghaX0r</span></code>: Dead Argument Hacking (BUGPOINT USE ONLY; DO NOT USE)</a></p></li>
<li><p><a class="reference internal" href="#extract-blocks-extract-basic-blocks-from-module-for-bugpoint-use" id="id105"><code class="docutils literal notranslate"><span class="pre">-extract-blocks</span></code>: Extract Basic Blocks From Module (for bugpoint use)</a></p></li>
<li><p><a class="reference internal" href="#instnamer-assign-names-to-anonymous-instructions" id="id106"><code class="docutils literal notranslate"><span class="pre">-instnamer</span></code>: Assign names to anonymous instructions</a></p></li>
<li><p><a class="reference internal" href="#verify-module-verifier" id="id107"><code class="docutils literal notranslate"><span class="pre">-verify</span></code>: Module Verifier</a></p></li>
<li><p><a class="reference internal" href="#view-cfg-view-cfg-of-function" id="id108"><code class="docutils literal notranslate"><span class="pre">-view-cfg</span></code>: View CFG of function</a></p></li>
<li><p><a class="reference internal" href="#view-cfg-only-view-cfg-of-function-with-no-function-bodies" id="id109"><code class="docutils literal notranslate"><span class="pre">-view-cfg-only</span></code>: View CFG of function (with no function bodies)</a></p></li>
<li><p><a class="reference internal" href="#view-dom-view-dominance-tree-of-function" id="id110"><code class="docutils literal notranslate"><span class="pre">-view-dom</span></code>: View dominance tree of function</a></p></li>
<li><p><a class="reference internal" href="#view-dom-only-view-dominance-tree-of-function-with-no-function-bodies" id="id111"><code class="docutils literal notranslate"><span class="pre">-view-dom-only</span></code>: View dominance tree of function (with no function bodies)</a></p></li>
<li><p><a class="reference internal" href="#view-postdom-view-postdominance-tree-of-function" id="id112"><code class="docutils literal notranslate"><span class="pre">-view-postdom</span></code>: View postdominance tree of function</a></p></li>
<li><p><a class="reference internal" href="#view-postdom-only-view-postdominance-tree-of-function-with-no-function-bodies" id="id113"><code class="docutils literal notranslate"><span class="pre">-view-postdom-only</span></code>: View postdominance tree of function (with no function bodies)</a></p></li>
<li><p><a class="reference internal" href="#transform-warning-report-missed-forced-transformations" id="id114"><code class="docutils literal notranslate"><span class="pre">-transform-warning</span></code>: Report missed forced transformations</a></p></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="introduction">
<h2><a class="toc-backref" href="#id1">Introduction</a><a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
<p>This document serves as a high level summary of the optimization features that
LLVM provides.  Optimizations are implemented as Passes that traverse some
portion of a program to either collect information or transform the program.
The table below divides the passes that LLVM provides into three categories.
Analysis passes compute information that other passes can use or for debugging
or program visualization purposes.  Transform passes can use (or invalidate)
the analysis passes.  Transform passes all mutate the program in some way.
Utility passes provides some utility but don’t otherwise fit categorization.
For example passes to extract functions to bitcode or write a module to bitcode
are neither analysis nor transform passes.  The table of contents above
provides a quick summary of each pass and links to the more complete pass
description later in the document.</p>
</div>
<div class="section" id="analysis-passes">
<h2><a class="toc-backref" href="#id2">Analysis Passes</a><a class="headerlink" href="#analysis-passes" title="Permalink to this headline">¶</a></h2>
<p>This section describes the LLVM Analysis Passes.</p>
<div class="section" id="aa-eval-exhaustive-alias-analysis-precision-evaluator">
<h3><a class="toc-backref" href="#id3"><code class="docutils literal notranslate"><span class="pre">-aa-eval</span></code>: Exhaustive Alias Analysis Precision Evaluator</a><a class="headerlink" href="#aa-eval-exhaustive-alias-analysis-precision-evaluator" title="Permalink to this headline">¶</a></h3>
<p>This is a simple N^2 alias analysis accuracy evaluator.  Basically, for each
function in the program, it simply queries to see how the alias analysis
implementation answers alias queries between each pair of pointers in the
function.</p>
<p>This is inspired and adapted from code by: Naveen Neelakantam, Francesco
Spadini, and Wojciech Stryjewski.</p>
</div>
<div class="section" id="basicaa-basic-alias-analysis-stateless-aa-impl">
<h3><a class="toc-backref" href="#id4"><code class="docutils literal notranslate"><span class="pre">-basicaa</span></code>: Basic Alias Analysis (stateless AA impl)</a><a class="headerlink" href="#basicaa-basic-alias-analysis-stateless-aa-impl" title="Permalink to this headline">¶</a></h3>
<p>A basic alias analysis pass that implements identities (two different globals
cannot alias, etc), but does no stateful analysis.</p>
</div>
<div class="section" id="basiccg-basic-callgraph-construction">
<h3><a class="toc-backref" href="#id5"><code class="docutils literal notranslate"><span class="pre">-basiccg</span></code>: Basic CallGraph Construction</a><a class="headerlink" href="#basiccg-basic-callgraph-construction" title="Permalink to this headline">¶</a></h3>
<p>Yet to be written.</p>
</div>
<div class="section" id="count-aa-count-alias-analysis-query-responses">
<h3><a class="toc-backref" href="#id6"><code class="docutils literal notranslate"><span class="pre">-count-aa</span></code>: Count Alias Analysis Query Responses</a><a class="headerlink" href="#count-aa-count-alias-analysis-query-responses" title="Permalink to this headline">¶</a></h3>
<p>A pass which can be used to count how many alias queries are being made and how
the alias analysis implementation being used responds.</p>
</div>
<div class="section" id="da-dependence-analysis">
<span id="passes-da"></span><h3><a class="toc-backref" href="#id7"><code class="docutils literal notranslate"><span class="pre">-da</span></code>: Dependence Analysis</a><a class="headerlink" href="#da-dependence-analysis" title="Permalink to this headline">¶</a></h3>
<p>Dependence analysis framework, which is used to detect dependences in memory
accesses.</p>
</div>
<div class="section" id="debug-aa-aa-use-debugger">
<h3><a class="toc-backref" href="#id8"><code class="docutils literal notranslate"><span class="pre">-debug-aa</span></code>: AA use debugger</a><a class="headerlink" href="#debug-aa-aa-use-debugger" title="Permalink to this headline">¶</a></h3>
<p>This simple pass checks alias analysis users to ensure that if they create a
new value, they do not query AA without informing it of the value.  It acts as
a shim over any other AA pass you want.</p>
<p>Yes keeping track of every value in the program is expensive, but this is a
debugging pass.</p>
</div>
<div class="section" id="domfrontier-dominance-frontier-construction">
<h3><a class="toc-backref" href="#id9"><code class="docutils literal notranslate"><span class="pre">-domfrontier</span></code>: Dominance Frontier Construction</a><a class="headerlink" href="#domfrontier-dominance-frontier-construction" title="Permalink to this headline">¶</a></h3>
<p>This pass is a simple dominator construction algorithm for finding forward
dominator frontiers.</p>
</div>
<div class="section" id="domtree-dominator-tree-construction">
<h3><a class="toc-backref" href="#id10"><code class="docutils literal notranslate"><span class="pre">-domtree</span></code>: Dominator Tree Construction</a><a class="headerlink" href="#domtree-dominator-tree-construction" title="Permalink to this headline">¶</a></h3>
<p>This pass is a simple dominator construction algorithm for finding forward
dominators.</p>
</div>
<div class="section" id="dot-callgraph-print-call-graph-to-dot-file">
<h3><a class="toc-backref" href="#id11"><code class="docutils literal notranslate"><span class="pre">-dot-callgraph</span></code>: Print Call Graph to “dot” file</a><a class="headerlink" href="#dot-callgraph-print-call-graph-to-dot-file" title="Permalink to this headline">¶</a></h3>
<p>This pass, only available in <code class="docutils literal notranslate"><span class="pre">opt</span></code>, prints the call graph into a <code class="docutils literal notranslate"><span class="pre">.dot</span></code>
graph.  This graph can then be processed with the “dot” tool to convert it to
postscript or some other suitable format.</p>
</div>
<div class="section" id="dot-cfg-print-cfg-of-function-to-dot-file">
<h3><a class="toc-backref" href="#id12"><code class="docutils literal notranslate"><span class="pre">-dot-cfg</span></code>: Print CFG of function to “dot” file</a><a class="headerlink" href="#dot-cfg-print-cfg-of-function-to-dot-file" title="Permalink to this headline">¶</a></h3>
<p>This pass, only available in <code class="docutils literal notranslate"><span class="pre">opt</span></code>, prints the control flow graph into a
<code class="docutils literal notranslate"><span class="pre">.dot</span></code> graph.  This graph can then be processed with the <strong class="program">dot</strong> tool
to convert it to postscript or some other suitable format.</p>
</div>
<div class="section" id="dot-cfg-only-print-cfg-of-function-to-dot-file-with-no-function-bodies">
<h3><a class="toc-backref" href="#id13"><code class="docutils literal notranslate"><span class="pre">-dot-cfg-only</span></code>: Print CFG of function to “dot” file (with no function bodies)</a><a class="headerlink" href="#dot-cfg-only-print-cfg-of-function-to-dot-file-with-no-function-bodies" title="Permalink to this headline">¶</a></h3>
<p>This pass, only available in <code class="docutils literal notranslate"><span class="pre">opt</span></code>, prints the control flow graph into a
<code class="docutils literal notranslate"><span class="pre">.dot</span></code> graph, omitting the function bodies.  This graph can then be processed
with the <strong class="program">dot</strong> tool to convert it to postscript or some other suitable
format.</p>
</div>
<div class="section" id="dot-dom-print-dominance-tree-of-function-to-dot-file">
<h3><a class="toc-backref" href="#id14"><code class="docutils literal notranslate"><span class="pre">-dot-dom</span></code>: Print dominance tree of function to “dot” file</a><a class="headerlink" href="#dot-dom-print-dominance-tree-of-function-to-dot-file" title="Permalink to this headline">¶</a></h3>
<p>This pass, only available in <code class="docutils literal notranslate"><span class="pre">opt</span></code>, prints the dominator tree into a <code class="docutils literal notranslate"><span class="pre">.dot</span></code>
graph.  This graph can then be processed with the <strong class="program">dot</strong> tool to
convert it to postscript or some other suitable format.</p>
</div>
<div class="section" id="dot-dom-only-print-dominance-tree-of-function-to-dot-file-with-no-function-bodies">
<h3><a class="toc-backref" href="#id15"><code class="docutils literal notranslate"><span class="pre">-dot-dom-only</span></code>: Print dominance tree of function to “dot” file (with no function bodies)</a><a class="headerlink" href="#dot-dom-only-print-dominance-tree-of-function-to-dot-file-with-no-function-bodies" title="Permalink to this headline">¶</a></h3>
<p>This pass, only available in <code class="docutils literal notranslate"><span class="pre">opt</span></code>, prints the dominator tree into a <code class="docutils literal notranslate"><span class="pre">.dot</span></code>
graph, omitting the function bodies.  This graph can then be processed with the
<strong class="program">dot</strong> tool to convert it to postscript or some other suitable format.</p>
</div>
<div class="section" id="dot-postdom-print-postdominance-tree-of-function-to-dot-file">
<h3><a class="toc-backref" href="#id16"><code class="docutils literal notranslate"><span class="pre">-dot-postdom</span></code>: Print postdominance tree of function to “dot” file</a><a class="headerlink" href="#dot-postdom-print-postdominance-tree-of-function-to-dot-file" title="Permalink to this headline">¶</a></h3>
<p>This pass, only available in <code class="docutils literal notranslate"><span class="pre">opt</span></code>, prints the post dominator tree into a
<code class="docutils literal notranslate"><span class="pre">.dot</span></code> graph.  This graph can then be processed with the <strong class="program">dot</strong> tool
to convert it to postscript or some other suitable format.</p>
</div>
<div class="section" id="dot-postdom-only-print-postdominance-tree-of-function-to-dot-file-with-no-function-bodies">
<h3><a class="toc-backref" href="#id17"><code class="docutils literal notranslate"><span class="pre">-dot-postdom-only</span></code>: Print postdominance tree of function to “dot” file (with no function bodies)</a><a class="headerlink" href="#dot-postdom-only-print-postdominance-tree-of-function-to-dot-file-with-no-function-bodies" title="Permalink to this headline">¶</a></h3>
<p>This pass, only available in <code class="docutils literal notranslate"><span class="pre">opt</span></code>, prints the post dominator tree into a
<code class="docutils literal notranslate"><span class="pre">.dot</span></code> graph, omitting the function bodies.  This graph can then be processed
with the <strong class="program">dot</strong> tool to convert it to postscript or some other suitable
format.</p>
</div>
<div class="section" id="globalsmodref-aa-simple-mod-ref-analysis-for-globals">
<h3><a class="toc-backref" href="#id18"><code class="docutils literal notranslate"><span class="pre">-globalsmodref-aa</span></code>: Simple mod/ref analysis for globals</a><a class="headerlink" href="#globalsmodref-aa-simple-mod-ref-analysis-for-globals" title="Permalink to this headline">¶</a></h3>
<p>This simple pass provides alias and mod/ref information for global values that
do not have their address taken, and keeps track of whether functions read or
write memory (are “pure”).  For this simple (but very common) case, we can
provide pretty accurate and useful information.</p>
</div>
<div class="section" id="instcount-counts-the-various-types-of-instructions">
<h3><a class="toc-backref" href="#id19"><code class="docutils literal notranslate"><span class="pre">-instcount</span></code>: Counts the various types of <code class="docutils literal notranslate"><span class="pre">Instruction</span></code>s</a><a class="headerlink" href="#instcount-counts-the-various-types-of-instructions" title="Permalink to this headline">¶</a></h3>
<p>This pass collects the count of all instructions and reports them.</p>
</div>
<div class="section" id="intervals-interval-partition-construction">
<h3><a class="toc-backref" href="#id20"><code class="docutils literal notranslate"><span class="pre">-intervals</span></code>: Interval Partition Construction</a><a class="headerlink" href="#intervals-interval-partition-construction" title="Permalink to this headline">¶</a></h3>
<p>This analysis calculates and represents the interval partition of a function,
or a preexisting interval partition.</p>
<p>In this way, the interval partition may be used to reduce a flow graph down to
its degenerate single node interval partition (unless it is irreducible).</p>
</div>
<div class="section" id="iv-users-induction-variable-users">
<h3><a class="toc-backref" href="#id21"><code class="docutils literal notranslate"><span class="pre">-iv-users</span></code>: Induction Variable Users</a><a class="headerlink" href="#iv-users-induction-variable-users" title="Permalink to this headline">¶</a></h3>
<p>Bookkeeping for “interesting” users of expressions computed from induction
variables.</p>
</div>
<div class="section" id="lazy-value-info-lazy-value-information-analysis">
<h3><a class="toc-backref" href="#id22"><code class="docutils literal notranslate"><span class="pre">-lazy-value-info</span></code>: Lazy Value Information Analysis</a><a class="headerlink" href="#lazy-value-info-lazy-value-information-analysis" title="Permalink to this headline">¶</a></h3>
<p>Interface for lazy computation of value constraint information.</p>
</div>
<div class="section" id="libcall-aa-libcall-alias-analysis">
<h3><a class="toc-backref" href="#id23"><code class="docutils literal notranslate"><span class="pre">-libcall-aa</span></code>: LibCall Alias Analysis</a><a class="headerlink" href="#libcall-aa-libcall-alias-analysis" title="Permalink to this headline">¶</a></h3>
<p>LibCall Alias Analysis.</p>
</div>
<div class="section" id="lint-statically-lint-checks-llvm-ir">
<h3><a class="toc-backref" href="#id24"><code class="docutils literal notranslate"><span class="pre">-lint</span></code>: Statically lint-checks LLVM IR</a><a class="headerlink" href="#lint-statically-lint-checks-llvm-ir" title="Permalink to this headline">¶</a></h3>
<p>This pass statically checks for common and easily-identified constructs which
produce undefined or likely unintended behavior in LLVM IR.</p>
<p>It is not a guarantee of correctness, in two ways.  First, it isn’t
comprehensive.  There are checks which could be done statically which are not
yet implemented.  Some of these are indicated by TODO comments, but those
aren’t comprehensive either.  Second, many conditions cannot be checked
statically.  This pass does no dynamic instrumentation, so it can’t check for
all possible problems.</p>
<p>Another limitation is that it assumes all code will be executed.  A store
through a null pointer in a basic block which is never reached is harmless, but
this pass will warn about it anyway.</p>
<p>Optimization passes may make conditions that this pass checks for more or less
obvious.  If an optimization pass appears to be introducing a warning, it may
be that the optimization pass is merely exposing an existing condition in the
code.</p>
<p>This code may be run before <a class="reference internal" href="#passes-instcombine"><span class="std std-ref">instcombine</span></a>.  In many
cases, instcombine checks for the same kinds of things and turns instructions
with undefined behavior into unreachable (or equivalent).  Because of this,
this pass makes some effort to look through bitcasts and so on.</p>
</div>
<div class="section" id="loops-natural-loop-information">
<h3><a class="toc-backref" href="#id25"><code class="docutils literal notranslate"><span class="pre">-loops</span></code>: Natural Loop Information</a><a class="headerlink" href="#loops-natural-loop-information" title="Permalink to this headline">¶</a></h3>
<p>This analysis is used to identify natural loops and determine the loop depth of
various nodes of the CFG.  Note that the loops identified may actually be
several natural loops that share the same header node… not just a single
natural loop.</p>
</div>
<div class="section" id="memdep-memory-dependence-analysis">
<h3><a class="toc-backref" href="#id26"><code class="docutils literal notranslate"><span class="pre">-memdep</span></code>: Memory Dependence Analysis</a><a class="headerlink" href="#memdep-memory-dependence-analysis" title="Permalink to this headline">¶</a></h3>
<p>An analysis that determines, for a given memory operation, what preceding
memory operations it depends on.  It builds on alias analysis information, and
tries to provide a lazy, caching interface to a common kind of alias
information query.</p>
</div>
<div class="section" id="module-debuginfo-decodes-module-level-debug-info">
<h3><a class="toc-backref" href="#id27"><code class="docutils literal notranslate"><span class="pre">-module-debuginfo</span></code>: Decodes module-level debug info</a><a class="headerlink" href="#module-debuginfo-decodes-module-level-debug-info" title="Permalink to this headline">¶</a></h3>
<p>This pass decodes the debug info metadata in a module and prints in a
(sufficiently-prepared-) human-readable form.</p>
<p>For example, run this pass from <code class="docutils literal notranslate"><span class="pre">opt</span></code> along with the <code class="docutils literal notranslate"><span class="pre">-analyze</span></code> option, and
it’ll print to standard output.</p>
</div>
<div class="section" id="postdomfrontier-post-dominance-frontier-construction">
<h3><a class="toc-backref" href="#id28"><code class="docutils literal notranslate"><span class="pre">-postdomfrontier</span></code>: Post-Dominance Frontier Construction</a><a class="headerlink" href="#postdomfrontier-post-dominance-frontier-construction" title="Permalink to this headline">¶</a></h3>
<p>This pass is a simple post-dominator construction algorithm for finding
post-dominator frontiers.</p>
</div>
<div class="section" id="postdomtree-post-dominator-tree-construction">
<h3><a class="toc-backref" href="#id29"><code class="docutils literal notranslate"><span class="pre">-postdomtree</span></code>: Post-Dominator Tree Construction</a><a class="headerlink" href="#postdomtree-post-dominator-tree-construction" title="Permalink to this headline">¶</a></h3>
<p>This pass is a simple post-dominator construction algorithm for finding
post-dominators.</p>
</div>
<div class="section" id="print-alias-sets-alias-set-printer">
<h3><a class="toc-backref" href="#id30"><code class="docutils literal notranslate"><span class="pre">-print-alias-sets</span></code>: Alias Set Printer</a><a class="headerlink" href="#print-alias-sets-alias-set-printer" title="Permalink to this headline">¶</a></h3>
<p>Yet to be written.</p>
</div>
<div class="section" id="print-callgraph-print-a-call-graph">
<h3><a class="toc-backref" href="#id31"><code class="docutils literal notranslate"><span class="pre">-print-callgraph</span></code>: Print a call graph</a><a class="headerlink" href="#print-callgraph-print-a-call-graph" title="Permalink to this headline">¶</a></h3>
<p>This pass, only available in <code class="docutils literal notranslate"><span class="pre">opt</span></code>, prints the call graph to standard error
in a human-readable form.</p>
</div>
<div class="section" id="print-callgraph-sccs-print-sccs-of-the-call-graph">
<h3><a class="toc-backref" href="#id32"><code class="docutils literal notranslate"><span class="pre">-print-callgraph-sccs</span></code>: Print SCCs of the Call Graph</a><a class="headerlink" href="#print-callgraph-sccs-print-sccs-of-the-call-graph" title="Permalink to this headline">¶</a></h3>
<p>This pass, only available in <code class="docutils literal notranslate"><span class="pre">opt</span></code>, prints the SCCs of the call graph to
standard error in a human-readable form.</p>
</div>
<div class="section" id="print-cfg-sccs-print-sccs-of-each-function-cfg">
<h3><a class="toc-backref" href="#id33"><code class="docutils literal notranslate"><span class="pre">-print-cfg-sccs</span></code>: Print SCCs of each function CFG</a><a class="headerlink" href="#print-cfg-sccs-print-sccs-of-each-function-cfg" title="Permalink to this headline">¶</a></h3>
<p>This pass, only available in <code class="docutils literal notranslate"><span class="pre">opt</span></code>, printsthe SCCs of each function CFG to
standard error in a human-readable fom.</p>
</div>
<div class="section" id="print-dom-info-dominator-info-printer">
<h3><a class="toc-backref" href="#id34"><code class="docutils literal notranslate"><span class="pre">-print-dom-info</span></code>: Dominator Info Printer</a><a class="headerlink" href="#print-dom-info-dominator-info-printer" title="Permalink to this headline">¶</a></h3>
<p>Dominator Info Printer.</p>
</div>
<div class="section" id="print-externalfnconstants-print-external-fn-callsites-passed-constants">
<h3><a class="toc-backref" href="#id35"><code class="docutils literal notranslate"><span class="pre">-print-externalfnconstants</span></code>: Print external fn callsites passed constants</a><a class="headerlink" href="#print-externalfnconstants-print-external-fn-callsites-passed-constants" title="Permalink to this headline">¶</a></h3>
<p>This pass, only available in <code class="docutils literal notranslate"><span class="pre">opt</span></code>, prints out call sites to external
functions that are called with constant arguments.  This can be useful when
looking for standard library functions we should constant fold or handle in
alias analyses.</p>
</div>
<div class="section" id="print-function-print-function-to-stderr">
<h3><a class="toc-backref" href="#id36"><code class="docutils literal notranslate"><span class="pre">-print-function</span></code>: Print function to stderr</a><a class="headerlink" href="#print-function-print-function-to-stderr" title="Permalink to this headline">¶</a></h3>
<p>The <code class="docutils literal notranslate"><span class="pre">PrintFunctionPass</span></code> class is designed to be pipelined with other
<code class="docutils literal notranslate"><span class="pre">FunctionPasses</span></code>, and prints out the functions of the module as they are
processed.</p>
</div>
<div class="section" id="print-module-print-module-to-stderr">
<h3><a class="toc-backref" href="#id37"><code class="docutils literal notranslate"><span class="pre">-print-module</span></code>: Print module to stderr</a><a class="headerlink" href="#print-module-print-module-to-stderr" title="Permalink to this headline">¶</a></h3>
<p>This pass simply prints out the entire module when it is executed.</p>
</div>
<div class="section" id="print-used-types-find-used-types">
<span id="passes-print-used-types"></span><h3><a class="toc-backref" href="#id38"><code class="docutils literal notranslate"><span class="pre">-print-used-types</span></code>: Find Used Types</a><a class="headerlink" href="#print-used-types-find-used-types" title="Permalink to this headline">¶</a></h3>
<p>This pass is used to seek out all of the types in use by the program.  Note
that this analysis explicitly does not include types only used by the symbol
table.</p>
</div>
<div class="section" id="regions-detect-single-entry-single-exit-regions">
<h3><a class="toc-backref" href="#id39"><code class="docutils literal notranslate"><span class="pre">-regions</span></code>: Detect single entry single exit regions</a><a class="headerlink" href="#regions-detect-single-entry-single-exit-regions" title="Permalink to this headline">¶</a></h3>
<p>The <code class="docutils literal notranslate"><span class="pre">RegionInfo</span></code> pass detects single entry single exit regions in a function,
where a region is defined as any subgraph that is connected to the remaining
graph at only two spots.  Furthermore, an hierarchical region tree is built.</p>
</div>
<div class="section" id="scalar-evolution-scalar-evolution-analysis">
<h3><a class="toc-backref" href="#id40"><code class="docutils literal notranslate"><span class="pre">-scalar-evolution</span></code>: Scalar Evolution Analysis</a><a class="headerlink" href="#scalar-evolution-scalar-evolution-analysis" title="Permalink to this headline">¶</a></h3>
<p>The <code class="docutils literal notranslate"><span class="pre">ScalarEvolution</span></code> analysis can be used to analyze and catagorize scalar
expressions in loops.  It specializes in recognizing general induction
variables, representing them with the abstract and opaque <code class="docutils literal notranslate"><span class="pre">SCEV</span></code> class.
Given this analysis, trip counts of loops and other important properties can be
obtained.</p>
<p>This analysis is primarily useful for induction variable substitution and
strength reduction.</p>
</div>
<div class="section" id="scev-aa-scalarevolution-based-alias-analysis">
<h3><a class="toc-backref" href="#id41"><code class="docutils literal notranslate"><span class="pre">-scev-aa</span></code>: ScalarEvolution-based Alias Analysis</a><a class="headerlink" href="#scev-aa-scalarevolution-based-alias-analysis" title="Permalink to this headline">¶</a></h3>
<p>Simple alias analysis implemented in terms of <code class="docutils literal notranslate"><span class="pre">ScalarEvolution</span></code> queries.</p>
<p>This differs from traditional loop dependence analysis in that it tests for
dependencies within a single iteration of a loop, rather than dependencies
between different iterations.</p>
<p><code class="docutils literal notranslate"><span class="pre">ScalarEvolution</span></code> has a more complete understanding of pointer arithmetic
than <code class="docutils literal notranslate"><span class="pre">BasicAliasAnalysis</span></code>’ collection of ad-hoc analyses.</p>
</div>
<div class="section" id="stack-safety-stack-safety-analysis">
<h3><a class="toc-backref" href="#id42"><code class="docutils literal notranslate"><span class="pre">-stack-safety</span></code>: Stack Safety Analysis</a><a class="headerlink" href="#stack-safety-stack-safety-analysis" title="Permalink to this headline">¶</a></h3>
<p>The <code class="docutils literal notranslate"><span class="pre">StackSafety</span></code> analysis can be used to determine if stack allocated
variables can be considered safe from memory access bugs.</p>
<p>This analysis’ primary purpose is to be used by sanitizers to avoid unnecessary
instrumentation of safe variables.</p>
</div>
<div class="section" id="targetdata-target-data-layout">
<h3><a class="toc-backref" href="#id43"><code class="docutils literal notranslate"><span class="pre">-targetdata</span></code>: Target Data Layout</a><a class="headerlink" href="#targetdata-target-data-layout" title="Permalink to this headline">¶</a></h3>
<p>Provides other passes access to information on how the size and alignment
required by the target ABI for various data types.</p>
</div>
</div>
<div class="section" id="transform-passes">
<h2><a class="toc-backref" href="#id44">Transform Passes</a><a class="headerlink" href="#transform-passes" title="Permalink to this headline">¶</a></h2>
<p>This section describes the LLVM Transform Passes.</p>
<div class="section" id="adce-aggressive-dead-code-elimination">
<h3><a class="toc-backref" href="#id45"><code class="docutils literal notranslate"><span class="pre">-adce</span></code>: Aggressive Dead Code Elimination</a><a class="headerlink" href="#adce-aggressive-dead-code-elimination" title="Permalink to this headline">¶</a></h3>
<p>ADCE aggressively tries to eliminate code.  This pass is similar to <a class="reference internal" href="#passes-dce"><span class="std std-ref">DCE</span></a> but it assumes that values are dead until proven otherwise.  This
is similar to <a class="reference internal" href="#passes-sccp"><span class="std std-ref">SCCP</span></a>, except applied to the liveness of
values.</p>
</div>
<div class="section" id="always-inline-inliner-for-always-inline-functions">
<h3><a class="toc-backref" href="#id46"><code class="docutils literal notranslate"><span class="pre">-always-inline</span></code>: Inliner for <code class="docutils literal notranslate"><span class="pre">always_inline</span></code> functions</a><a class="headerlink" href="#always-inline-inliner-for-always-inline-functions" title="Permalink to this headline">¶</a></h3>
<p>A custom inliner that handles only functions that are marked as “always
inline”.</p>
</div>
<div class="section" id="argpromotion-promote-by-reference-arguments-to-scalars">
<h3><a class="toc-backref" href="#id47"><code class="docutils literal notranslate"><span class="pre">-argpromotion</span></code>: Promote ‘by reference’ arguments to scalars</a><a class="headerlink" href="#argpromotion-promote-by-reference-arguments-to-scalars" title="Permalink to this headline">¶</a></h3>
<p>This pass promotes “by reference” arguments to be “by value” arguments.  In
practice, this means looking for internal functions that have pointer
arguments.  If it can prove, through the use of alias analysis, that an
argument is <em>only</em> loaded, then it can pass the value into the function instead
of the address of the value.  This can cause recursive simplification of code
and lead to the elimination of allocas (especially in C++ template code like
the STL).</p>
<p>This pass also handles aggregate arguments that are passed into a function,
scalarizing them if the elements of the aggregate are only loaded.  Note that
it refuses to scalarize aggregates which would require passing in more than
three operands to the function, because passing thousands of operands for a
large array or structure is unprofitable!</p>
<p>Note that this transformation could also be done for arguments that are only
stored to (returning the value instead), but does not currently.  This case
would be best handled when and if LLVM starts supporting multiple return values
from functions.</p>
</div>
<div class="section" id="bb-vectorize-basic-block-vectorization">
<h3><a class="toc-backref" href="#id48"><code class="docutils literal notranslate"><span class="pre">-bb-vectorize</span></code>: Basic-Block Vectorization</a><a class="headerlink" href="#bb-vectorize-basic-block-vectorization" title="Permalink to this headline">¶</a></h3>
<p>This pass combines instructions inside basic blocks to form vector
instructions.  It iterates over each basic block, attempting to pair compatible
instructions, repeating this process until no additional pairs are selected for
vectorization.  When the outputs of some pair of compatible instructions are
used as inputs by some other pair of compatible instructions, those pairs are
part of a potential vectorization chain.  Instruction pairs are only fused into
vector instructions when they are part of a chain longer than some threshold
length.  Moreover, the pass attempts to find the best possible chain for each
pair of compatible instructions.  These heuristics are intended to prevent
vectorization in cases where it would not yield a performance increase of the
resulting code.</p>
</div>
<div class="section" id="block-placement-profile-guided-basic-block-placement">
<h3><a class="toc-backref" href="#id49"><code class="docutils literal notranslate"><span class="pre">-block-placement</span></code>: Profile Guided Basic Block Placement</a><a class="headerlink" href="#block-placement-profile-guided-basic-block-placement" title="Permalink to this headline">¶</a></h3>
<p>This pass is a very simple profile guided basic block placement algorithm.  The
idea is to put frequently executed blocks together at the start of the function
and hopefully increase the number of fall-through conditional branches.  If
there is no profile information for a particular function, this pass basically
orders blocks in depth-first order.</p>
</div>
<div class="section" id="break-crit-edges-break-critical-edges-in-cfg">
<h3><a class="toc-backref" href="#id50"><code class="docutils literal notranslate"><span class="pre">-break-crit-edges</span></code>: Break critical edges in CFG</a><a class="headerlink" href="#break-crit-edges-break-critical-edges-in-cfg" title="Permalink to this headline">¶</a></h3>
<p>Break all of the critical edges in the CFG by inserting a dummy basic block.
It may be “required” by passes that cannot deal with critical edges.  This
transformation obviously invalidates the CFG, but can update forward dominator
(set, immediate dominators, tree, and frontier) information.</p>
</div>
<div class="section" id="codegenprepare-optimize-for-code-generation">
<h3><a class="toc-backref" href="#id51"><code class="docutils literal notranslate"><span class="pre">-codegenprepare</span></code>: Optimize for code generation</a><a class="headerlink" href="#codegenprepare-optimize-for-code-generation" title="Permalink to this headline">¶</a></h3>
<p>This pass munges the code in the input function to better prepare it for
SelectionDAG-based code generation.  This works around limitations in its
basic-block-at-a-time approach.  It should eventually be removed.</p>
</div>
<div class="section" id="constmerge-merge-duplicate-global-constants">
<h3><a class="toc-backref" href="#id52"><code class="docutils literal notranslate"><span class="pre">-constmerge</span></code>: Merge Duplicate Global Constants</a><a class="headerlink" href="#constmerge-merge-duplicate-global-constants" title="Permalink to this headline">¶</a></h3>
<p>Merges duplicate global constants together into a single constant that is
shared.  This is useful because some passes (i.e., TraceValues) insert a lot of
string constants into the program, regardless of whether or not an existing
string is available.</p>
</div>
<div class="section" id="constprop-simple-constant-propagation">
<h3><a class="toc-backref" href="#id53"><code class="docutils literal notranslate"><span class="pre">-constprop</span></code>: Simple constant propagation</a><a class="headerlink" href="#constprop-simple-constant-propagation" title="Permalink to this headline">¶</a></h3>
<p>This pass implements constant propagation and merging.  It looks for
instructions involving only constant operands and replaces them with a constant
value instead of an instruction.  For example:</p>
<div class="highlight-llvm notranslate"><div class="highlight"><pre><span></span><span class="k">add</span> <span class="k">i32</span> <span class="m">1</span><span class="p">,</span> <span class="m">2</span>
</pre></div>
</div>
<p>becomes</p>
<div class="highlight-llvm notranslate"><div class="highlight"><pre><span></span><span class="k">i32</span> <span class="m">3</span>
</pre></div>
</div>
<p>NOTE: this pass has a habit of making definitions be dead.  It is a good idea
to run a <a class="reference internal" href="#passes-die"><span class="std std-ref">Dead Instruction Elimination</span></a> pass sometime after
running this pass.</p>
</div>
<div class="section" id="dce-dead-code-elimination">
<span id="passes-dce"></span><h3><a class="toc-backref" href="#id54"><code class="docutils literal notranslate"><span class="pre">-dce</span></code>: Dead Code Elimination</a><a class="headerlink" href="#dce-dead-code-elimination" title="Permalink to this headline">¶</a></h3>
<p>Dead code elimination is similar to <a class="reference internal" href="#passes-die"><span class="std std-ref">dead instruction elimination</span></a>, but it rechecks instructions that were used by removed
instructions to see if they are newly dead.</p>
</div>
<div class="section" id="deadargelim-dead-argument-elimination">
<h3><a class="toc-backref" href="#id55"><code class="docutils literal notranslate"><span class="pre">-deadargelim</span></code>: Dead Argument Elimination</a><a class="headerlink" href="#deadargelim-dead-argument-elimination" title="Permalink to this headline">¶</a></h3>
<p>This pass deletes dead arguments from internal functions.  Dead argument
elimination removes arguments which are directly dead, as well as arguments
only passed into function calls as dead arguments of other functions.  This
pass also deletes dead arguments in a similar way.</p>
<p>This pass is often useful as a cleanup pass to run after aggressive
interprocedural passes, which add possibly-dead arguments.</p>
</div>
<div class="section" id="deadtypeelim-dead-type-elimination">
<h3><a class="toc-backref" href="#id56"><code class="docutils literal notranslate"><span class="pre">-deadtypeelim</span></code>: Dead Type Elimination</a><a class="headerlink" href="#deadtypeelim-dead-type-elimination" title="Permalink to this headline">¶</a></h3>
<p>This pass is used to cleanup the output of GCC.  It eliminate names for types
that are unused in the entire translation unit, using the <a class="reference internal" href="#passes-print-used-types"><span class="std std-ref">find used types</span></a> pass.</p>
</div>
<div class="section" id="die-dead-instruction-elimination">
<span id="passes-die"></span><h3><a class="toc-backref" href="#id57"><code class="docutils literal notranslate"><span class="pre">-die</span></code>: Dead Instruction Elimination</a><a class="headerlink" href="#die-dead-instruction-elimination" title="Permalink to this headline">¶</a></h3>
<p>Dead instruction elimination performs a single pass over the function, removing
instructions that are obviously dead.</p>
</div>
<div class="section" id="dse-dead-store-elimination">
<h3><a class="toc-backref" href="#id58"><code class="docutils literal notranslate"><span class="pre">-dse</span></code>: Dead Store Elimination</a><a class="headerlink" href="#dse-dead-store-elimination" title="Permalink to this headline">¶</a></h3>
<p>A trivial dead store elimination that only considers basic-block local
redundant stores.</p>
</div>
<div class="section" id="functionattrs-deduce-function-attributes">
<span id="passes-functionattrs"></span><h3><a class="toc-backref" href="#id59"><code class="docutils literal notranslate"><span class="pre">-functionattrs</span></code>: Deduce function attributes</a><a class="headerlink" href="#functionattrs-deduce-function-attributes" title="Permalink to this headline">¶</a></h3>
<p>A simple interprocedural pass which walks the call-graph, looking for functions
which do not access or only read non-local memory, and marking them
<code class="docutils literal notranslate"><span class="pre">readnone</span></code>/<code class="docutils literal notranslate"><span class="pre">readonly</span></code>.  In addition, it marks function arguments (of
pointer type) “<code class="docutils literal notranslate"><span class="pre">nocapture</span></code>” if a call to the function does not create any
copies of the pointer value that outlive the call.  This more or less means
that the pointer is only dereferenced, and not returned from the function or
stored in a global.  This pass is implemented as a bottom-up traversal of the
call-graph.</p>
</div>
<div class="section" id="globaldce-dead-global-elimination">
<h3><a class="toc-backref" href="#id60"><code class="docutils literal notranslate"><span class="pre">-globaldce</span></code>: Dead Global Elimination</a><a class="headerlink" href="#globaldce-dead-global-elimination" title="Permalink to this headline">¶</a></h3>
<p>This transform is designed to eliminate unreachable internal globals from the
program.  It uses an aggressive algorithm, searching out globals that are known
to be alive.  After it finds all of the globals which are needed, it deletes
whatever is left over.  This allows it to delete recursive chunks of the
program which are unreachable.</p>
</div>
<div class="section" id="globalopt-global-variable-optimizer">
<h3><a class="toc-backref" href="#id61"><code class="docutils literal notranslate"><span class="pre">-globalopt</span></code>: Global Variable Optimizer</a><a class="headerlink" href="#globalopt-global-variable-optimizer" title="Permalink to this headline">¶</a></h3>
<p>This pass transforms simple global variables that never have their address
taken.  If obviously true, it marks read/write globals as constant, deletes
variables only stored to, etc.</p>
</div>
<div class="section" id="gvn-global-value-numbering">
<h3><a class="toc-backref" href="#id62"><code class="docutils literal notranslate"><span class="pre">-gvn</span></code>: Global Value Numbering</a><a class="headerlink" href="#gvn-global-value-numbering" title="Permalink to this headline">¶</a></h3>
<p>This pass performs global value numbering to eliminate fully and partially
redundant instructions.  It also performs redundant load elimination.</p>
</div>
<div class="section" id="indvars-canonicalize-induction-variables">
<span id="passes-indvars"></span><h3><a class="toc-backref" href="#id63"><code class="docutils literal notranslate"><span class="pre">-indvars</span></code>: Canonicalize Induction Variables</a><a class="headerlink" href="#indvars-canonicalize-induction-variables" title="Permalink to this headline">¶</a></h3>
<p>This transformation analyzes and transforms the induction variables (and
computations derived from them) into simpler forms suitable for subsequent
analysis and transformation.</p>
<p>This transformation makes the following changes to each loop with an
identifiable induction variable:</p>
<ul class="simple">
<li><p>All loops are transformed to have a <em>single</em> canonical induction variable
which starts at zero and steps by one.</p></li>
<li><p>The canonical induction variable is guaranteed to be the first PHI node in
the loop header block.</p></li>
<li><p>Any pointer arithmetic recurrences are raised to use array subscripts.</p></li>
</ul>
<p>If the trip count of a loop is computable, this pass also makes the following
changes:</p>
<ul>
<li><p>The exit condition for the loop is canonicalized to compare the induction
value against the exit value.  This turns loops like:</p>
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="p">(</span><span class="n">i</span> <span class="o">=</span> <span class="mi">7</span><span class="p">;</span> <span class="n">i</span><span class="o">*</span><span class="n">i</span> <span class="o">&lt;</span> <span class="mi">1000</span><span class="p">;</span> <span class="o">++</span><span class="n">i</span><span class="p">)</span>

<span class="n">into</span>
</pre></div>
</div>
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="p">(</span><span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">i</span> <span class="o">!=</span> <span class="mi">25</span><span class="p">;</span> <span class="o">++</span><span class="n">i</span><span class="p">)</span>
</pre></div>
</div>
</li>
<li><p>Any use outside of the loop of an expression derived from the indvar is
changed to compute the derived value outside of the loop, eliminating the
dependence on the exit value of the induction variable.  If the only purpose
of the loop is to compute the exit value of some derived expression, this
transformation will make the loop dead.</p></li>
</ul>
<p>This transformation should be followed by strength reduction after all of the
desired loop transformations have been performed.  Additionally, on targets
where it is profitable, the loop could be transformed to count down to zero
(the “do loop” optimization).</p>
</div>
<div class="section" id="inline-function-integration-inlining">
<h3><a class="toc-backref" href="#id64"><code class="docutils literal notranslate"><span class="pre">-inline</span></code>: Function Integration/Inlining</a><a class="headerlink" href="#inline-function-integration-inlining" title="Permalink to this headline">¶</a></h3>
<p>Bottom-up inlining of functions into callees.</p>
</div>
<div class="section" id="instcombine-combine-redundant-instructions">
<span id="passes-instcombine"></span><h3><a class="toc-backref" href="#id65"><code class="docutils literal notranslate"><span class="pre">-instcombine</span></code>: Combine redundant instructions</a><a class="headerlink" href="#instcombine-combine-redundant-instructions" title="Permalink to this headline">¶</a></h3>
<p>Combine instructions to form fewer, simple instructions.  This pass does not
modify the CFG. This pass is where algebraic simplification happens.</p>
<p>This pass combines things like:</p>
<div class="highlight-llvm notranslate"><div class="highlight"><pre><span></span><span class="nv">%Y</span> <span class="p">=</span> <span class="k">add</span> <span class="k">i32</span> <span class="nv">%X</span><span class="p">,</span> <span class="m">1</span>
<span class="nv">%Z</span> <span class="p">=</span> <span class="k">add</span> <span class="k">i32</span> <span class="nv">%Y</span><span class="p">,</span> <span class="m">1</span>
</pre></div>
</div>
<p>into:</p>
<div class="highlight-llvm notranslate"><div class="highlight"><pre><span></span><span class="nv">%Z</span> <span class="p">=</span> <span class="k">add</span> <span class="k">i32</span> <span class="nv">%X</span><span class="p">,</span> <span class="m">2</span>
</pre></div>
</div>
<p>This is a simple worklist driven algorithm.</p>
<p>This pass guarantees that the following canonicalizations are performed on the
program:</p>
<ol class="arabic simple">
<li><p>If a binary operator has a constant operand, it is moved to the right-hand
side.</p></li>
<li><p>Bitwise operators with constant operands are always grouped so that shifts
are performed first, then <code class="docutils literal notranslate"><span class="pre">or</span></code>s, then <code class="docutils literal notranslate"><span class="pre">and</span></code>s, then <code class="docutils literal notranslate"><span class="pre">xor</span></code>s.</p></li>
<li><p>Compare instructions are converted from <code class="docutils literal notranslate"><span class="pre">&lt;</span></code>, <code class="docutils literal notranslate"><span class="pre">&gt;</span></code>, <code class="docutils literal notranslate"><span class="pre">≤</span></code>, or <code class="docutils literal notranslate"><span class="pre">≥</span></code> to
<code class="docutils literal notranslate"><span class="pre">=</span></code> or <code class="docutils literal notranslate"><span class="pre">≠</span></code> if possible.</p></li>
<li><p>All <code class="docutils literal notranslate"><span class="pre">cmp</span></code> instructions on boolean values are replaced with logical
operations.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">add</span> <span class="pre">X,</span> <span class="pre">X</span></code> is represented as <code class="docutils literal notranslate"><span class="pre">mul</span> <span class="pre">X,</span> <span class="pre">2</span></code> ⇒ <code class="docutils literal notranslate"><span class="pre">shl</span> <span class="pre">X,</span> <span class="pre">1</span></code></p></li>
<li><p>Multiplies with a constant power-of-two argument are transformed into
shifts.</p></li>
<li><p>… etc.</p></li>
</ol>
<p>This pass can also simplify calls to specific well-known function calls (e.g.
runtime library functions).  For example, a call <code class="docutils literal notranslate"><span class="pre">exit(3)</span></code> that occurs within
the <code class="docutils literal notranslate"><span class="pre">main()</span></code> function can be transformed into simply <code class="docutils literal notranslate"><span class="pre">return</span> <span class="pre">3</span></code>. Whether or
not library calls are simplified is controlled by the
<a class="reference internal" href="#passes-functionattrs"><span class="std std-ref">-functionattrs</span></a> pass and LLVM’s knowledge of
library calls on different targets.</p>
</div>
<div class="section" id="aggressive-instcombine-combine-expression-patterns">
<span id="passes-aggressive-instcombine"></span><h3><a class="toc-backref" href="#id66"><code class="docutils literal notranslate"><span class="pre">-aggressive-instcombine</span></code>: Combine expression patterns</a><a class="headerlink" href="#aggressive-instcombine-combine-expression-patterns" title="Permalink to this headline">¶</a></h3>
<p>Combine expression patterns to form expressions with fewer, simple instructions.
This pass does not modify the CFG.</p>
<p>For example, this pass reduce width of expressions post-dominated by TruncInst
into smaller width when applicable.</p>
<p>It differs from instcombine pass in that it contains pattern optimization that
requires higher complexity than the O(1), thus, it should run fewer times than
instcombine pass.</p>
</div>
<div class="section" id="internalize-internalize-global-symbols">
<h3><a class="toc-backref" href="#id67"><code class="docutils literal notranslate"><span class="pre">-internalize</span></code>: Internalize Global Symbols</a><a class="headerlink" href="#internalize-internalize-global-symbols" title="Permalink to this headline">¶</a></h3>
<p>This pass loops over all of the functions in the input module, looking for a
main function.  If a main function is found, all other functions and all global
variables with initializers are marked as internal.</p>
</div>
<div class="section" id="ipconstprop-interprocedural-constant-propagation">
<h3><a class="toc-backref" href="#id68"><code class="docutils literal notranslate"><span class="pre">-ipconstprop</span></code>: Interprocedural constant propagation</a><a class="headerlink" href="#ipconstprop-interprocedural-constant-propagation" title="Permalink to this headline">¶</a></h3>
<p>This pass implements an <em>extremely</em> simple interprocedural constant propagation
pass.  It could certainly be improved in many different ways, like using a
worklist.  This pass makes arguments dead, but does not remove them.  The
existing dead argument elimination pass should be run after this to clean up
the mess.</p>
</div>
<div class="section" id="ipsccp-interprocedural-sparse-conditional-constant-propagation">
<h3><a class="toc-backref" href="#id69"><code class="docutils literal notranslate"><span class="pre">-ipsccp</span></code>: Interprocedural Sparse Conditional Constant Propagation</a><a class="headerlink" href="#ipsccp-interprocedural-sparse-conditional-constant-propagation" title="Permalink to this headline">¶</a></h3>
<p>An interprocedural variant of <a class="reference internal" href="#passes-sccp"><span class="std std-ref">Sparse Conditional Constant Propagation</span></a>.</p>
</div>
<div class="section" id="jump-threading-jump-threading">
<h3><a class="toc-backref" href="#id70"><code class="docutils literal notranslate"><span class="pre">-jump-threading</span></code>: Jump Threading</a><a class="headerlink" href="#jump-threading-jump-threading" title="Permalink to this headline">¶</a></h3>
<p>Jump threading tries to find distinct threads of control flow running through a
basic block.  This pass looks at blocks that have multiple predecessors and
multiple successors.  If one or more of the predecessors of the block can be
proven to always cause a jump to one of the successors, we forward the edge
from the predecessor to the successor by duplicating the contents of this
block.</p>
<p>An example of when this can occur is code like this:</p>
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="p">()</span> <span class="p">{</span> <span class="p">...</span>
  <span class="n">X</span> <span class="o">=</span> <span class="mi">4</span><span class="p">;</span>
<span class="p">}</span>
<span class="k">if</span> <span class="p">(</span><span class="n">X</span> <span class="o">&lt;</span> <span class="mi">3</span><span class="p">)</span> <span class="p">{</span>
</pre></div>
</div>
<p>In this case, the unconditional branch at the end of the first if can be
revectored to the false side of the second if.</p>
</div>
<div class="section" id="lcssa-loop-closed-ssa-form-pass">
<h3><a class="toc-backref" href="#id71"><code class="docutils literal notranslate"><span class="pre">-lcssa</span></code>: Loop-Closed SSA Form Pass</a><a class="headerlink" href="#lcssa-loop-closed-ssa-form-pass" title="Permalink to this headline">¶</a></h3>
<p>This pass transforms loops by placing phi nodes at the end of the loops for all
values that are live across the loop boundary.  For example, it turns the left
into the right code:</p>
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="p">(...)</span>                <span class="k">for</span> <span class="p">(...)</span>
    <span class="k">if</span> <span class="p">(</span><span class="n">c</span><span class="p">)</span>                   <span class="k">if</span> <span class="p">(</span><span class="n">c</span><span class="p">)</span>
        <span class="n">X1</span> <span class="o">=</span> <span class="p">...</span>                 <span class="n">X1</span> <span class="o">=</span> <span class="p">...</span>
    <span class="k">else</span>                     <span class="k">else</span>
        <span class="n">X2</span> <span class="o">=</span> <span class="p">...</span>                 <span class="n">X2</span> <span class="o">=</span> <span class="p">...</span>
    <span class="n">X3</span> <span class="o">=</span> <span class="n">phi</span><span class="p">(</span><span class="n">X1</span><span class="p">,</span> <span class="n">X2</span><span class="p">)</span>         <span class="n">X3</span> <span class="o">=</span> <span class="n">phi</span><span class="p">(</span><span class="n">X1</span><span class="p">,</span> <span class="n">X2</span><span class="p">)</span>
<span class="p">...</span> <span class="o">=</span> <span class="n">X3</span> <span class="o">+</span> <span class="mi">4</span>              <span class="n">X4</span> <span class="o">=</span> <span class="n">phi</span><span class="p">(</span><span class="n">X3</span><span class="p">)</span>
                            <span class="p">...</span> <span class="o">=</span> <span class="n">X4</span> <span class="o">+</span> <span class="mi">4</span>
</pre></div>
</div>
<p>This is still valid LLVM; the extra phi nodes are purely redundant, and will be
trivially eliminated by <code class="docutils literal notranslate"><span class="pre">InstCombine</span></code>.  The major benefit of this
transformation is that it makes many other loop optimizations, such as
<code class="docutils literal notranslate"><span class="pre">LoopUnswitch</span></code>ing, simpler.</p>
</div>
<div class="section" id="licm-loop-invariant-code-motion">
<span id="passes-licm"></span><h3><a class="toc-backref" href="#id72"><code class="docutils literal notranslate"><span class="pre">-licm</span></code>: Loop Invariant Code Motion</a><a class="headerlink" href="#licm-loop-invariant-code-motion" title="Permalink to this headline">¶</a></h3>
<p>This pass performs loop invariant code motion, attempting to remove as much
code from the body of a loop as possible.  It does this by either hoisting code
into the preheader block, or by sinking code to the exit blocks if it is safe.
This pass also promotes must-aliased memory locations in the loop to live in
registers, thus hoisting and sinking “invariant” loads and stores.</p>
<p>This pass uses alias analysis for two purposes:</p>
<ol class="arabic">
<li><p>Moving loop invariant loads and calls out of loops.  If we can determine
that a load or call inside of a loop never aliases anything stored to, we
can hoist it or sink it like any other instruction.</p></li>
<li><p>Scalar Promotion of Memory.  If there is a store instruction inside of the
loop, we try to move the store to happen AFTER the loop instead of inside of
the loop.  This can only happen if a few conditions are true:</p>
<ol class="arabic simple">
<li><p>The pointer stored through is loop invariant.</p></li>
<li><p>There are no stores or loads in the loop which <em>may</em> alias the pointer.
There are no calls in the loop which mod/ref the pointer.</p></li>
</ol>
<p>If these conditions are true, we can promote the loads and stores in the
loop of the pointer to use a temporary alloca’d variable.  We then use the
<a class="reference internal" href="#passes-mem2reg"><span class="std std-ref">mem2reg</span></a> functionality to construct the appropriate
SSA form for the variable.</p>
</li>
</ol>
</div>
<div class="section" id="loop-deletion-delete-dead-loops">
<h3><a class="toc-backref" href="#id73"><code class="docutils literal notranslate"><span class="pre">-loop-deletion</span></code>: Delete dead loops</a><a class="headerlink" href="#loop-deletion-delete-dead-loops" title="Permalink to this headline">¶</a></h3>
<p>This file implements the Dead Loop Deletion Pass.  This pass is responsible for
eliminating loops with non-infinite computable trip counts that have no side
effects or volatile instructions, and do not contribute to the computation of
the function’s return value.</p>
</div>
<div class="section" id="loop-extract-extract-loops-into-new-functions">
<span id="passes-loop-extract"></span><h3><a class="toc-backref" href="#id74"><code class="docutils literal notranslate"><span class="pre">-loop-extract</span></code>: Extract loops into new functions</a><a class="headerlink" href="#loop-extract-extract-loops-into-new-functions" title="Permalink to this headline">¶</a></h3>
<p>A pass wrapper around the <code class="docutils literal notranslate"><span class="pre">ExtractLoop()</span></code> scalar transformation to extract
each top-level loop into its own new function.  If the loop is the <em>only</em> loop
in a given function, it is not touched.  This is a pass most useful for
debugging via bugpoint.</p>
</div>
<div class="section" id="loop-extract-single-extract-at-most-one-loop-into-a-new-function">
<h3><a class="toc-backref" href="#id75"><code class="docutils literal notranslate"><span class="pre">-loop-extract-single</span></code>: Extract at most one loop into a new function</a><a class="headerlink" href="#loop-extract-single-extract-at-most-one-loop-into-a-new-function" title="Permalink to this headline">¶</a></h3>
<p>Similar to <a class="reference internal" href="#passes-loop-extract"><span class="std std-ref">Extract loops into new functions</span></a>, this
pass extracts one natural loop from the program into a function if it can.
This is used by <strong class="program">bugpoint</strong>.</p>
</div>
<div class="section" id="loop-reduce-loop-strength-reduction">
<h3><a class="toc-backref" href="#id76"><code class="docutils literal notranslate"><span class="pre">-loop-reduce</span></code>: Loop Strength Reduction</a><a class="headerlink" href="#loop-reduce-loop-strength-reduction" title="Permalink to this headline">¶</a></h3>
<p>This pass performs a strength reduction on array references inside loops that
have as one or more of their components the loop induction variable.  This is
accomplished by creating a new value to hold the initial value of the array
access for the first iteration, and then creating a new GEP instruction in the
loop to increment the value by the appropriate amount.</p>
</div>
<div class="section" id="loop-rotate-rotate-loops">
<h3><a class="toc-backref" href="#id77"><code class="docutils literal notranslate"><span class="pre">-loop-rotate</span></code>: Rotate Loops</a><a class="headerlink" href="#loop-rotate-rotate-loops" title="Permalink to this headline">¶</a></h3>
<p>A simple loop rotation transformation.</p>
</div>
<div class="section" id="loop-simplify-canonicalize-natural-loops">
<h3><a class="toc-backref" href="#id78"><code class="docutils literal notranslate"><span class="pre">-loop-simplify</span></code>: Canonicalize natural loops</a><a class="headerlink" href="#loop-simplify-canonicalize-natural-loops" title="Permalink to this headline">¶</a></h3>
<p>This pass performs several transformations to transform natural loops into a
simpler form, which makes subsequent analyses and transformations simpler and
more effective.</p>
<p>Loop pre-header insertion guarantees that there is a single, non-critical entry
edge from outside of the loop to the loop header.  This simplifies a number of
analyses and transformations, such as <a class="reference internal" href="#passes-licm"><span class="std std-ref">LICM</span></a>.</p>
<p>Loop exit-block insertion guarantees that all exit blocks from the loop (blocks
which are outside of the loop that have predecessors inside of the loop) only
have predecessors from inside of the loop (and are thus dominated by the loop
header).  This simplifies transformations such as store-sinking that are built
into LICM.</p>
<p>This pass also guarantees that loops will have exactly one backedge.</p>
<p>Note that the <a class="reference internal" href="#passes-simplifycfg"><span class="std std-ref">simplifycfg</span></a> pass will clean up blocks
which are split out but end up being unnecessary, so usage of this pass should
not pessimize generated code.</p>
<p>This pass obviously modifies the CFG, but updates loop information and
dominator information.</p>
</div>
<div class="section" id="loop-unroll-unroll-loops">
<h3><a class="toc-backref" href="#id79"><code class="docutils literal notranslate"><span class="pre">-loop-unroll</span></code>: Unroll loops</a><a class="headerlink" href="#loop-unroll-unroll-loops" title="Permalink to this headline">¶</a></h3>
<p>This pass implements a simple loop unroller.  It works best when loops have
been canonicalized by the <a class="reference internal" href="#passes-indvars"><span class="std std-ref">indvars</span></a> pass, allowing it to
determine the trip counts of loops easily.</p>
</div>
<div class="section" id="loop-unroll-and-jam-unroll-and-jam-loops">
<h3><a class="toc-backref" href="#id80"><code class="docutils literal notranslate"><span class="pre">-loop-unroll-and-jam</span></code>: Unroll and Jam loops</a><a class="headerlink" href="#loop-unroll-and-jam-unroll-and-jam-loops" title="Permalink to this headline">¶</a></h3>
<p>This pass implements a simple unroll and jam classical loop optimisation pass.
It transforms loop from:</p>
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">i</span><span class="p">..</span> <span class="n">i</span><span class="o">+=</span> <span class="mi">1</span>              <span class="k">for</span> <span class="n">i</span><span class="p">..</span> <span class="n">i</span><span class="o">+=</span> <span class="mi">4</span>
  <span class="k">for</span> <span class="n">j</span><span class="p">..</span>                    <span class="k">for</span> <span class="n">j</span><span class="p">..</span>
    <span class="n">code</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">)</span>                 <span class="n">code</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">)</span>
                               <span class="n">code</span><span class="p">(</span><span class="n">i</span><span class="o">+</span><span class="mi">1</span><span class="p">,</span> <span class="n">j</span><span class="p">)</span>
                               <span class="n">code</span><span class="p">(</span><span class="n">i</span><span class="o">+</span><span class="mi">2</span><span class="p">,</span> <span class="n">j</span><span class="p">)</span>
                               <span class="n">code</span><span class="p">(</span><span class="n">i</span><span class="o">+</span><span class="mi">3</span><span class="p">,</span> <span class="n">j</span><span class="p">)</span>
                           <span class="n">remainder</span> <span class="n">loop</span>
</pre></div>
</div>
<p>Which can be seen as unrolling the outer loop and “jamming” (fusing) the inner
loops into one. When variables or loads can be shared in the new inner loop, this
can lead to significant performance improvements. It uses
<a class="reference internal" href="#passes-da"><span class="std std-ref">Dependence Analysis</span></a> for proving the transformations are safe.</p>
</div>
<div class="section" id="loop-unswitch-unswitch-loops">
<h3><a class="toc-backref" href="#id81"><code class="docutils literal notranslate"><span class="pre">-loop-unswitch</span></code>: Unswitch loops</a><a class="headerlink" href="#loop-unswitch-unswitch-loops" title="Permalink to this headline">¶</a></h3>
<p>This pass transforms loops that contain branches on loop-invariant conditions
to have multiple loops.  For example, it turns the left into the right code:</p>
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="p">(...)</span>                  <span class="k">if</span> <span class="p">(</span><span class="n">lic</span><span class="p">)</span>
    <span class="n">A</span>                          <span class="k">for</span> <span class="p">(...)</span>
    <span class="k">if</span> <span class="p">(</span><span class="n">lic</span><span class="p">)</span>                       <span class="n">A</span><span class="p">;</span> <span class="n">B</span><span class="p">;</span> <span class="n">C</span>
        <span class="n">B</span>                  <span class="k">else</span>
    <span class="n">C</span>                          <span class="k">for</span> <span class="p">(...)</span>
                                   <span class="n">A</span><span class="p">;</span> <span class="n">C</span>
</pre></div>
</div>
<p>This can increase the size of the code exponentially (doubling it every time a
loop is unswitched) so we only unswitch if the resultant code will be smaller
than a threshold.</p>
<p>This pass expects <a class="reference internal" href="#passes-licm"><span class="std std-ref">LICM</span></a> to be run before it to hoist
invariant conditions out of the loop, to make the unswitching opportunity
obvious.</p>
</div>
<div class="section" id="loweratomic-lower-atomic-intrinsics-to-non-atomic-form">
<h3><a class="toc-backref" href="#id82"><code class="docutils literal notranslate"><span class="pre">-loweratomic</span></code>: Lower atomic intrinsics to non-atomic form</a><a class="headerlink" href="#loweratomic-lower-atomic-intrinsics-to-non-atomic-form" title="Permalink to this headline">¶</a></h3>
<p>This pass lowers atomic intrinsics to non-atomic form for use in a known
non-preemptible environment.</p>
<p>The pass does not verify that the environment is non-preemptible (in general
this would require knowledge of the entire call graph of the program including
any libraries which may not be available in bitcode form); it simply lowers
every atomic intrinsic.</p>
</div>
<div class="section" id="lowerinvoke-lower-invokes-to-calls-for-unwindless-code-generators">
<h3><a class="toc-backref" href="#id83"><code class="docutils literal notranslate"><span class="pre">-lowerinvoke</span></code>: Lower invokes to calls, for unwindless code generators</a><a class="headerlink" href="#lowerinvoke-lower-invokes-to-calls-for-unwindless-code-generators" title="Permalink to this headline">¶</a></h3>
<p>This transformation is designed for use by code generators which do not yet
support stack unwinding.  This pass converts <code class="docutils literal notranslate"><span class="pre">invoke</span></code> instructions to
<code class="docutils literal notranslate"><span class="pre">call</span></code> instructions, so that any exception-handling <code class="docutils literal notranslate"><span class="pre">landingpad</span></code> blocks
become dead code (which can be removed by running the <code class="docutils literal notranslate"><span class="pre">-simplifycfg</span></code> pass
afterwards).</p>
</div>
<div class="section" id="lowerswitch-lower-switchinsts-to-branches">
<h3><a class="toc-backref" href="#id84"><code class="docutils literal notranslate"><span class="pre">-lowerswitch</span></code>: Lower <code class="docutils literal notranslate"><span class="pre">SwitchInst</span></code>s to branches</a><a class="headerlink" href="#lowerswitch-lower-switchinsts-to-branches" title="Permalink to this headline">¶</a></h3>
<p>Rewrites switch instructions with a sequence of branches, which allows targets
to get away with not implementing the switch instruction until it is
convenient.</p>
</div>
<div class="section" id="mem2reg-promote-memory-to-register">
<span id="passes-mem2reg"></span><h3><a class="toc-backref" href="#id85"><code class="docutils literal notranslate"><span class="pre">-mem2reg</span></code>: Promote Memory to Register</a><a class="headerlink" href="#mem2reg-promote-memory-to-register" title="Permalink to this headline">¶</a></h3>
<p>This file promotes memory references to be register references.  It promotes
alloca instructions which only have loads and stores as uses.  An <code class="docutils literal notranslate"><span class="pre">alloca</span></code> is
transformed by using dominator frontiers to place phi nodes, then traversing
the function in depth-first order to rewrite loads and stores as appropriate.
This is just the standard SSA construction algorithm to construct “pruned” SSA
form.</p>
</div>
<div class="section" id="memcpyopt-memcpy-optimization">
<h3><a class="toc-backref" href="#id86"><code class="docutils literal notranslate"><span class="pre">-memcpyopt</span></code>: MemCpy Optimization</a><a class="headerlink" href="#memcpyopt-memcpy-optimization" title="Permalink to this headline">¶</a></h3>
<p>This pass performs various transformations related to eliminating <code class="docutils literal notranslate"><span class="pre">memcpy</span></code>
calls, or transforming sets of stores into <code class="docutils literal notranslate"><span class="pre">memset</span></code>s.</p>
</div>
<div class="section" id="mergefunc-merge-functions">
<h3><a class="toc-backref" href="#id87"><code class="docutils literal notranslate"><span class="pre">-mergefunc</span></code>: Merge Functions</a><a class="headerlink" href="#mergefunc-merge-functions" title="Permalink to this headline">¶</a></h3>
<p>This pass looks for equivalent functions that are mergable and folds them.</p>
<p>Total-ordering is introduced among the functions set: we define comparison
that answers for every two functions which of them is greater. It allows to
arrange functions into the binary tree.</p>
<p>For every new function we check for equivalent in tree.</p>
<p>If equivalent exists we fold such functions. If both functions are overridable,
we move the functionality into a new internal function and leave two
overridable thunks to it.</p>
<p>If there is no equivalent, then we add this function to tree.</p>
<p>Lookup routine has O(log(n)) complexity, while whole merging process has
complexity of O(n*log(n)).</p>
<p>Read
<a class="reference internal" href="MergeFunctions.html"><span class="doc">this</span></a>
article for more details.</p>
</div>
<div class="section" id="mergereturn-unify-function-exit-nodes">
<h3><a class="toc-backref" href="#id88"><code class="docutils literal notranslate"><span class="pre">-mergereturn</span></code>: Unify function exit nodes</a><a class="headerlink" href="#mergereturn-unify-function-exit-nodes" title="Permalink to this headline">¶</a></h3>
<p>Ensure that functions have at most one <code class="docutils literal notranslate"><span class="pre">ret</span></code> instruction in them.
Additionally, it keeps track of which node is the new exit node of the CFG.</p>
</div>
<div class="section" id="partial-inliner-partial-inliner">
<h3><a class="toc-backref" href="#id89"><code class="docutils literal notranslate"><span class="pre">-partial-inliner</span></code>: Partial Inliner</a><a class="headerlink" href="#partial-inliner-partial-inliner" title="Permalink to this headline">¶</a></h3>
<p>This pass performs partial inlining, typically by inlining an <code class="docutils literal notranslate"><span class="pre">if</span></code> statement
that surrounds the body of the function.</p>
</div>
<div class="section" id="prune-eh-remove-unused-exception-handling-info">
<h3><a class="toc-backref" href="#id90"><code class="docutils literal notranslate"><span class="pre">-prune-eh</span></code>: Remove unused exception handling info</a><a class="headerlink" href="#prune-eh-remove-unused-exception-handling-info" title="Permalink to this headline">¶</a></h3>
<p>This file implements a simple interprocedural pass which walks the call-graph,
turning invoke instructions into call instructions if and only if the callee
cannot throw an exception.  It implements this as a bottom-up traversal of the
call-graph.</p>
</div>
<div class="section" id="reassociate-reassociate-expressions">
<h3><a class="toc-backref" href="#id91"><code class="docutils literal notranslate"><span class="pre">-reassociate</span></code>: Reassociate expressions</a><a class="headerlink" href="#reassociate-reassociate-expressions" title="Permalink to this headline">¶</a></h3>
<p>This pass reassociates commutative expressions in an order that is designed to
promote better constant propagation, GCSE, <a class="reference internal" href="#passes-licm"><span class="std std-ref">LICM</span></a>, PRE, etc.</p>
<p>For example: 4 + (x + 5) ⇒ x + (4 + 5)</p>
<p>In the implementation of this algorithm, constants are assigned rank = 0,
function arguments are rank = 1, and other values are assigned ranks
corresponding to the reverse post order traversal of current function (starting
at 2), which effectively gives values in deep loops higher rank than values not
in loops.</p>
</div>
<div class="section" id="reg2mem-demote-all-values-to-stack-slots">
<h3><a class="toc-backref" href="#id92"><code class="docutils literal notranslate"><span class="pre">-reg2mem</span></code>: Demote all values to stack slots</a><a class="headerlink" href="#reg2mem-demote-all-values-to-stack-slots" title="Permalink to this headline">¶</a></h3>
<p>This file demotes all registers to memory references.  It is intended to be the
inverse of <a class="reference internal" href="#passes-mem2reg"><span class="std std-ref">mem2reg</span></a>.  By converting to <code class="docutils literal notranslate"><span class="pre">load</span></code>
instructions, the only values live across basic blocks are <code class="docutils literal notranslate"><span class="pre">alloca</span></code>
instructions and <code class="docutils literal notranslate"><span class="pre">load</span></code> instructions before <code class="docutils literal notranslate"><span class="pre">phi</span></code> nodes.  It is intended
that this should make CFG hacking much easier.  To make later hacking easier,
the entry block is split into two, such that all introduced <code class="docutils literal notranslate"><span class="pre">alloca</span></code>
instructions (and nothing else) are in the entry block.</p>
</div>
<div class="section" id="sroa-scalar-replacement-of-aggregates">
<h3><a class="toc-backref" href="#id93"><code class="docutils literal notranslate"><span class="pre">-sroa</span></code>: Scalar Replacement of Aggregates</a><a class="headerlink" href="#sroa-scalar-replacement-of-aggregates" title="Permalink to this headline">¶</a></h3>
<p>The well-known scalar replacement of aggregates transformation.  This transform
breaks up <code class="docutils literal notranslate"><span class="pre">alloca</span></code> instructions of aggregate type (structure or array) into
individual <code class="docutils literal notranslate"><span class="pre">alloca</span></code> instructions for each member if possible.  Then, if
possible, it transforms the individual <code class="docutils literal notranslate"><span class="pre">alloca</span></code> instructions into nice clean
scalar SSA form.</p>
</div>
<div class="section" id="sccp-sparse-conditional-constant-propagation">
<span id="passes-sccp"></span><h3><a class="toc-backref" href="#id94"><code class="docutils literal notranslate"><span class="pre">-sccp</span></code>: Sparse Conditional Constant Propagation</a><a class="headerlink" href="#sccp-sparse-conditional-constant-propagation" title="Permalink to this headline">¶</a></h3>
<p>Sparse conditional constant propagation and merging, which can be summarized
as:</p>
<ul class="simple">
<li><p>Assumes values are constant unless proven otherwise</p></li>
<li><p>Assumes BasicBlocks are dead unless proven otherwise</p></li>
<li><p>Proves values to be constant, and replaces them with constants</p></li>
<li><p>Proves conditional branches to be unconditional</p></li>
</ul>
<p>Note that this pass has a habit of making definitions be dead.  It is a good
idea to run a <a class="reference internal" href="#passes-dce"><span class="std std-ref">DCE</span></a> pass sometime after running this pass.</p>
</div>
<div class="section" id="simplifycfg-simplify-the-cfg">
<span id="passes-simplifycfg"></span><h3><a class="toc-backref" href="#id95"><code class="docutils literal notranslate"><span class="pre">-simplifycfg</span></code>: Simplify the CFG</a><a class="headerlink" href="#simplifycfg-simplify-the-cfg" title="Permalink to this headline">¶</a></h3>
<p>Performs dead code elimination and basic block merging.  Specifically:</p>
<ul class="simple">
<li><p>Removes basic blocks with no predecessors.</p></li>
<li><p>Merges a basic block into its predecessor if there is only one and the
predecessor only has one successor.</p></li>
<li><p>Eliminates PHI nodes for basic blocks with a single predecessor.</p></li>
<li><p>Eliminates a basic block that only contains an unconditional branch.</p></li>
</ul>
</div>
<div class="section" id="sink-code-sinking">
<h3><a class="toc-backref" href="#id96"><code class="docutils literal notranslate"><span class="pre">-sink</span></code>: Code sinking</a><a class="headerlink" href="#sink-code-sinking" title="Permalink to this headline">¶</a></h3>
<p>This pass moves instructions into successor blocks, when possible, so that they
aren’t executed on paths where their results aren’t needed.</p>
</div>
<div class="section" id="strip-strip-all-symbols-from-a-module">
<h3><a class="toc-backref" href="#id97"><code class="docutils literal notranslate"><span class="pre">-strip</span></code>: Strip all symbols from a module</a><a class="headerlink" href="#strip-strip-all-symbols-from-a-module" title="Permalink to this headline">¶</a></h3>
<p>Performs code stripping.  This transformation can delete:</p>
<ul class="simple">
<li><p>names for virtual registers</p></li>
<li><p>symbols for internal globals and functions</p></li>
<li><p>debug information</p></li>
</ul>
<p>Note that this transformation makes code much less readable, so it should only
be used in situations where the strip utility would be used, such as reducing
code size or making it harder to reverse engineer code.</p>
</div>
<div class="section" id="strip-dead-debug-info-strip-debug-info-for-unused-symbols">
<h3><a class="toc-backref" href="#id98"><code class="docutils literal notranslate"><span class="pre">-strip-dead-debug-info</span></code>: Strip debug info for unused symbols</a><a class="headerlink" href="#strip-dead-debug-info-strip-debug-info-for-unused-symbols" title="Permalink to this headline">¶</a></h3>
<p>performs code stripping. this transformation can delete:</p>
<ul class="simple">
<li><p>names for virtual registers</p></li>
<li><p>symbols for internal globals and functions</p></li>
<li><p>debug information</p></li>
</ul>
<p>note that this transformation makes code much less readable, so it should only
be used in situations where the strip utility would be used, such as reducing
code size or making it harder to reverse engineer code.</p>
</div>
<div class="section" id="strip-dead-prototypes-strip-unused-function-prototypes">
<h3><a class="toc-backref" href="#id99"><code class="docutils literal notranslate"><span class="pre">-strip-dead-prototypes</span></code>: Strip Unused Function Prototypes</a><a class="headerlink" href="#strip-dead-prototypes-strip-unused-function-prototypes" title="Permalink to this headline">¶</a></h3>
<p>This pass loops over all of the functions in the input module, looking for dead
declarations and removes them.  Dead declarations are declarations of functions
for which no implementation is available (i.e., declarations for unused library
functions).</p>
</div>
<div class="section" id="strip-debug-declare-strip-all-llvm-dbg-declare-intrinsics">
<h3><a class="toc-backref" href="#id100"><code class="docutils literal notranslate"><span class="pre">-strip-debug-declare</span></code>: Strip all <code class="docutils literal notranslate"><span class="pre">llvm.dbg.declare</span></code> intrinsics</a><a class="headerlink" href="#strip-debug-declare-strip-all-llvm-dbg-declare-intrinsics" title="Permalink to this headline">¶</a></h3>
<p>This pass implements code stripping.  Specifically, it can delete:</p>
<ol class="arabic simple">
<li><p>names for virtual registers</p></li>
<li><p>symbols for internal globals and functions</p></li>
<li><p>debug information</p></li>
</ol>
<p>Note that this transformation makes code much less readable, so it should only
be used in situations where the ‘strip’ utility would be used, such as reducing
code size or making it harder to reverse engineer code.</p>
</div>
<div class="section" id="strip-nondebug-strip-all-symbols-except-dbg-symbols-from-a-module">
<h3><a class="toc-backref" href="#id101"><code class="docutils literal notranslate"><span class="pre">-strip-nondebug</span></code>: Strip all symbols, except dbg symbols, from a module</a><a class="headerlink" href="#strip-nondebug-strip-all-symbols-except-dbg-symbols-from-a-module" title="Permalink to this headline">¶</a></h3>
<p>This pass implements code stripping.  Specifically, it can delete:</p>
<ol class="arabic simple">
<li><p>names for virtual registers</p></li>
<li><p>symbols for internal globals and functions</p></li>
<li><p>debug information</p></li>
</ol>
<p>Note that this transformation makes code much less readable, so it should only
be used in situations where the ‘strip’ utility would be used, such as reducing
code size or making it harder to reverse engineer code.</p>
</div>
<div class="section" id="tailcallelim-tail-call-elimination">
<h3><a class="toc-backref" href="#id102"><code class="docutils literal notranslate"><span class="pre">-tailcallelim</span></code>: Tail Call Elimination</a><a class="headerlink" href="#tailcallelim-tail-call-elimination" title="Permalink to this headline">¶</a></h3>
<p>This file transforms calls of the current function (self recursion) followed by
a return instruction with a branch to the entry of the function, creating a
loop.  This pass also implements the following extensions to the basic
algorithm:</p>
<ol class="arabic simple">
<li><p>Trivial instructions between the call and return do not prevent the
transformation from taking place, though currently the analysis cannot
support moving any really useful instructions (only dead ones).</p></li>
<li><p>This pass transforms functions that are prevented from being tail recursive
by an associative expression to use an accumulator variable, thus compiling
the typical naive factorial or fib implementation into efficient code.</p></li>
<li><p>TRE is performed if the function returns void, if the return returns the
result returned by the call, or if the function returns a run-time constant
on all exits from the function.  It is possible, though unlikely, that the
return returns something else (like constant 0), and can still be TRE’d.  It
can be TRE’d if <em>all other</em> return instructions in the function return the
exact same value.</p></li>
<li><p>If it can prove that callees do not access theier caller stack frame, they
are marked as eligible for tail call elimination (by the code generator).</p></li>
</ol>
</div>
</div>
<div class="section" id="utility-passes">
<h2><a class="toc-backref" href="#id103">Utility Passes</a><a class="headerlink" href="#utility-passes" title="Permalink to this headline">¶</a></h2>
<p>This section describes the LLVM Utility Passes.</p>
<div class="section" id="deadarghax0r-dead-argument-hacking-bugpoint-use-only-do-not-use">
<h3><a class="toc-backref" href="#id104"><code class="docutils literal notranslate"><span class="pre">-deadarghaX0r</span></code>: Dead Argument Hacking (BUGPOINT USE ONLY; DO NOT USE)</a><a class="headerlink" href="#deadarghax0r-dead-argument-hacking-bugpoint-use-only-do-not-use" title="Permalink to this headline">¶</a></h3>
<p>Same as dead argument elimination, but deletes arguments to functions which are
external.  This is only for use by <a class="reference internal" href="Bugpoint.html"><span class="doc">bugpoint</span></a>.</p>
</div>
<div class="section" id="extract-blocks-extract-basic-blocks-from-module-for-bugpoint-use">
<h3><a class="toc-backref" href="#id105"><code class="docutils literal notranslate"><span class="pre">-extract-blocks</span></code>: Extract Basic Blocks From Module (for bugpoint use)</a><a class="headerlink" href="#extract-blocks-extract-basic-blocks-from-module-for-bugpoint-use" title="Permalink to this headline">¶</a></h3>
<p>This pass is used by bugpoint to extract all blocks from the module into their
own functions.</p>
</div>
<div class="section" id="instnamer-assign-names-to-anonymous-instructions">
<h3><a class="toc-backref" href="#id106"><code class="docutils literal notranslate"><span class="pre">-instnamer</span></code>: Assign names to anonymous instructions</a><a class="headerlink" href="#instnamer-assign-names-to-anonymous-instructions" title="Permalink to this headline">¶</a></h3>
<p>This is a little utility pass that gives instructions names, this is mostly
useful when diffing the effect of an optimization because deleting an unnamed
instruction can change all other instruction numbering, making the diff very
noisy.</p>
</div>
<div class="section" id="verify-module-verifier">
<span id="passes-verify"></span><h3><a class="toc-backref" href="#id107"><code class="docutils literal notranslate"><span class="pre">-verify</span></code>: Module Verifier</a><a class="headerlink" href="#verify-module-verifier" title="Permalink to this headline">¶</a></h3>
<p>Verifies an LLVM IR code.  This is useful to run after an optimization which is
undergoing testing.  Note that llvm-as verifies its input before emitting
bitcode, and also that malformed bitcode is likely to make LLVM crash.  All
language front-ends are therefore encouraged to verify their output before
performing optimizing transformations.</p>
<ol class="arabic simple">
<li><p>Both of a binary operator’s parameters are of the same type.</p></li>
<li><p>Verify that the indices of mem access instructions match other operands.</p></li>
<li><p>Verify that arithmetic and other things are only performed on first-class
types.  Verify that shifts and logicals only happen on integrals f.e.</p></li>
<li><p>All of the constants in a switch statement are of the correct type.</p></li>
<li><p>The code is in valid SSA form.</p></li>
<li><p>It is illegal to put a label into any other type (like a structure) or to
return one.</p></li>
<li><p>Only phi nodes can be self referential: <code class="docutils literal notranslate"><span class="pre">%x</span> <span class="pre">=</span> <span class="pre">add</span> <span class="pre">i32</span> <span class="pre">%x</span></code>, <code class="docutils literal notranslate"><span class="pre">%x</span></code> is
invalid.</p></li>
<li><p>PHI nodes must have an entry for each predecessor, with no extras.</p></li>
<li><p>PHI nodes must be the first thing in a basic block, all grouped together.</p></li>
<li><p>PHI nodes must have at least one entry.</p></li>
<li><p>All basic blocks should only end with terminator insts, not contain them.</p></li>
<li><p>The entry node to a function must not have predecessors.</p></li>
<li><p>All Instructions must be embedded into a basic block.</p></li>
<li><p>Functions cannot take a void-typed parameter.</p></li>
<li><p>Verify that a function’s argument list agrees with its declared type.</p></li>
<li><p>It is illegal to specify a name for a void value.</p></li>
<li><p>It is illegal to have an internal global value with no initializer.</p></li>
<li><p>It is illegal to have a <code class="docutils literal notranslate"><span class="pre">ret</span></code> instruction that returns a value that does
not agree with the function return value type.</p></li>
<li><p>Function call argument types match the function prototype.</p></li>
<li><p>All other things that are tested by asserts spread about the code.</p></li>
</ol>
<p>Note that this does not provide full security verification (like Java), but
instead just tries to ensure that code is well-formed.</p>
</div>
<div class="section" id="view-cfg-view-cfg-of-function">
<h3><a class="toc-backref" href="#id108"><code class="docutils literal notranslate"><span class="pre">-view-cfg</span></code>: View CFG of function</a><a class="headerlink" href="#view-cfg-view-cfg-of-function" title="Permalink to this headline">¶</a></h3>
<p>Displays the control flow graph using the GraphViz tool.</p>
</div>
<div class="section" id="view-cfg-only-view-cfg-of-function-with-no-function-bodies">
<h3><a class="toc-backref" href="#id109"><code class="docutils literal notranslate"><span class="pre">-view-cfg-only</span></code>: View CFG of function (with no function bodies)</a><a class="headerlink" href="#view-cfg-only-view-cfg-of-function-with-no-function-bodies" title="Permalink to this headline">¶</a></h3>
<p>Displays the control flow graph using the GraphViz tool, but omitting function
bodies.</p>
</div>
<div class="section" id="view-dom-view-dominance-tree-of-function">
<h3><a class="toc-backref" href="#id110"><code class="docutils literal notranslate"><span class="pre">-view-dom</span></code>: View dominance tree of function</a><a class="headerlink" href="#view-dom-view-dominance-tree-of-function" title="Permalink to this headline">¶</a></h3>
<p>Displays the dominator tree using the GraphViz tool.</p>
</div>
<div class="section" id="view-dom-only-view-dominance-tree-of-function-with-no-function-bodies">
<h3><a class="toc-backref" href="#id111"><code class="docutils literal notranslate"><span class="pre">-view-dom-only</span></code>: View dominance tree of function (with no function bodies)</a><a class="headerlink" href="#view-dom-only-view-dominance-tree-of-function-with-no-function-bodies" title="Permalink to this headline">¶</a></h3>
<p>Displays the dominator tree using the GraphViz tool, but omitting function
bodies.</p>
</div>
<div class="section" id="view-postdom-view-postdominance-tree-of-function">
<h3><a class="toc-backref" href="#id112"><code class="docutils literal notranslate"><span class="pre">-view-postdom</span></code>: View postdominance tree of function</a><a class="headerlink" href="#view-postdom-view-postdominance-tree-of-function" title="Permalink to this headline">¶</a></h3>
<p>Displays the post dominator tree using the GraphViz tool.</p>
</div>
<div class="section" id="view-postdom-only-view-postdominance-tree-of-function-with-no-function-bodies">
<h3><a class="toc-backref" href="#id113"><code class="docutils literal notranslate"><span class="pre">-view-postdom-only</span></code>: View postdominance tree of function (with no function bodies)</a><a class="headerlink" href="#view-postdom-only-view-postdominance-tree-of-function-with-no-function-bodies" title="Permalink to this headline">¶</a></h3>
<p>Displays the post dominator tree using the GraphViz tool, but omitting function
bodies.</p>
</div>
<div class="section" id="transform-warning-report-missed-forced-transformations">
<h3><a class="toc-backref" href="#id114"><code class="docutils literal notranslate"><span class="pre">-transform-warning</span></code>: Report missed forced transformations</a><a class="headerlink" href="#transform-warning-report-missed-forced-transformations" title="Permalink to this headline">¶</a></h3>
<p>Emits warnings about not yet applied forced transformations (e.g. from
<code class="docutils literal notranslate"><span class="pre">#pragma</span> <span class="pre">omp</span> <span class="pre">simd</span></code>).</p>
</div>
</div>
</div>


            <div class="clearer"></div>
          </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="YamlIO.html" title="YAML I/O"
             >next</a> |</li>
        <li class="right" >
          <a href="ReleaseNotes.html" title="LLVM 9.0.0 Release Notes"
             >previous</a> |</li>
  <li><a href="http://llvm.org/">LLVM Home</a>&nbsp;|&nbsp;</li>
  <li><a href="index.html">Documentation</a>&raquo;</li>

        <li class="nav-item nav-item-this"><a href="">LLVM’s Analysis and Transform Passes</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2003-2020, LLVM Project.
      Last updated on 2020-09-20.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
    </div>
  </body>
</html>